4

Over the years I have imported photos from iPhone to Mac and organized them in folder by month.

I now want to import all photos I have on the iPhone and compare those with the files that I've organized in folders over the years - if there are any missing.

Is there any tool (included in OSX or free/purchaseable) or other procedure that can compare folder content, with one folder holding the files in root and the other in many subfolders?

  • Compare what? number of files, size, kind, content ? – Ruskes Oct 18 '14 at 16:35
  • Comparing the existence of files, if missing/duplicates. – Numbers Oct 18 '14 at 16:36
  • That you can do with simple Terminal command "diff -rq folder1 folder2" – Ruskes Oct 18 '14 at 16:38
  • Much related to question 10252. – yurkennis Dec 21 '16 at 23:57
5

Terminal: diff

You can compare two folders in Terminal using the following command:

diff -rq /path/to/folder1 /path/to/folder2

To ignore folder hierarchy you can copy all the files out of a folder into a third folder, then compare these:

find /path/to/folder2 -mindepth 2 -type f -print -exec cp {} /path/to/folder3 \;
  • 1
    How would I check for all files in a folder, including those in subfolders? The subfolders won't be the same in the comparing parent folders. – Numbers Oct 18 '14 at 17:22
  • @Numbers I believe I misunderstood your question; I don't think you can do that but you could first copy all the photos out of the subfolders into a single second folder for comparison. Of course this depends how many photos you have. – grg Oct 18 '14 at 17:26
  • 1
    It's 25 GB and 100 folders and I'd like to keep them in the folders. But I'll find a way. – Numbers Oct 18 '14 at 17:28
  • 1
    @Numbers I understand you want to keep them in folders—I meant copy them just for the comparison, then delete the copied ones. For example, running something such as find /path/to/folder2 -mindepth 2 -type f -print -exec cp {} /path/to/folder3 \;, then the diff, then deleting the folder3. – grg Oct 18 '14 at 17:30
2

This is an old thread, I realise, but it looks like the question wasn't fully answered. I stumbled across this before trying to figure out roughly the same things for myself, so I thought I'd post an option in case others stumble across it...

Some of the answers were nearly there... and mine might be done more easily, but it works!

This will create a file of all the names of your photos:

find /Path/to/the/topmost folder/of/photos -mindepth 2 -type f -print | sed 's/^.*///' | sort > /tmp/photos-from-folders

If any are in folders owned by others, prepend with sudo and use >> to append those filenames to those already in the initial file.

use a similar command to create a second file containing all the filenames of your phone's photos.

You can just do a diff and send to a file with > or, if you know which set is biggest, use that as file1 and do

diff file1 file2 | egrep -v '<' > filediff-output

Of course, all the paths have been stripped by the sed in the intial find to generate just the filenames. If you see something that might be missing, you want to know where it is, so use

sudo find /Path/to/the/topmost folder/of/photos -name 'filename-you-want' -ls

and that will tell you where it is.

Hope this helps. I helped me work out what I need to keep from an old home directory of mine that's not in my new home directory. 65 Gig of space saved!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .