The following is a recipe for a comparison based on filenames alone, not based on file modification times or even content checksums. But it's a start :) Also, the below is to compare two directories that are both on Google Drive, but you can easily adapt it by generating a list of your local files instead with some call to ls
. (So obviously, the below is a recipe for Linux.)
1. Install and configure drive
drive
is a Linux command line client for Google Drive. The easiest is to install it from a package.
After that:
Change into the directory on your computer that includes your whole files synced from Google Drive:
cd /home/user/example-dir/
Initialize drive
with access to your Google Drive. This will ask you to visit a URL and paste the auth code you get there, and save this in a config file in the current directory.
drive init
2. Comparing directories
I found that for large Google Drive folders (36 GiB of small files in my case), starting by comparing directories and fixing cases of missing directories was a good first step. (Also because drive
has no option to copy directories without the files inside between two Google Drive folders. Not a problem if you compare between local and remote files only.)
drive list -directories -recursive -no-prompt -sort name "source dir" > DirDiff.1-source.txt
drive list -directories -recursive -no-prompt -
sort name "dest dir" > DirDiff.2-dest.txt
vim -es +"%s/^\/source dir\///g" +"wq" DirDiff.1-source.txt
vim -es +"%s/^\/dest dir\///g" +"wq" DirDiff.2-dest.txt
The drive
command obtain lists of directories from Google Drive, and the vim
commands remove the differing base directories from each path so that comparison will work properly.
Now to list the directories that are only in the source tree:
comm -23 <(sort < DirDiff.1-source.txt) <(sort < DirDiff.2-dest.txt) > DirDiff.3-missing.txt
And to show the directories that are only in the destination tree:
comm -13 <(sort < DirDiff.1-source.txt) <(sort < DirDiff.2-dest.txt) > DirDiff.4-added.txt
About using comm
like this, see here.
3. Comparing files
This works very similar to comparing directory trees:
drive list -recursive -no-prompt -sort name "source dir" > 1-source-files.txt
drive list -recursive -no-prompt -sort name "dest dir" > 2-dest-files.txt
vim -es +"%s/^\/source dir\///g" +"wq" DirDiff.1-source.txt
vim -es +"%s/^\/dest dir\///g" +"wq" DirDiff.2-dest.txt
To show the files only in the source tree:
comm -23 <(sort < FileDiff.1-source.txt) <(sort < FileDiff.2-dest.txt) > FileDiff.3-missing.txt
To show the files only in the destination tree:
comm -13 <(sort < FileDiff.1-source.txt) <(sort < FileDiff.2-dest.txt) > FileDiff.4-added.txt