Subtract files in folder A from folder B I've got folder A with 8000 images and folder B with 9000 images. Folder B contains the 8000 images from folder A as well as additional 1000 images. I would like to delete the 8000 images which are already in Folder A, leaving only the "new" 1000 images. 

Does anyone know an elegant way to get the job done? (btw. I can not sort them by date and get the newer ones)
You can use a simple bash script to do this::

for file in *.*; do if [ -f "/FolderA/${file}" ]; then rm "/FolderB/$file"; fi; done;


This script assumes you are already in FolderB, which is where you want to delete the files that already exist in FolderA.

You can tweak it if you know the extension of the image files (ie, .png, .gif, etc) and you have the exact folder names. So instead of *.* you can use *.png or *.gif.

A MUCH safer version:

for file in *.*; do if [ -f "/FolderA/${file}" ]; then mv "/FolderB/$file" ~/.Trash; fi; done;


This will move the file to the Trash.  Using rm is a one-way-street.  Once you hit enter on an rm command, it's done; that file is gone forever.  Move to the Trash to ensure you got the results you are looking for.