If your photos are in /path/to/photos/ and its subdirectories, and you want to move them to /path/to/master/ , and you want to select them by extension .jpg , .jpg , .png , .png , and etc .:.
find /path/to/photos \( -iname '*.jpg' -o -iname '*.png' \) -type f -exec mv -nv -t '/path/to/master' -- {} +
If you don’t want to filter by extension and just move everything (i.e. all files):
find /path/to/photos -type f -exec mv -nv -t '/path/to/master' -- {} +
The -n option is to not overwrite existing files (optional if you don't care) and -v to let mv show what it is doing (very optional).
The -t option for mv is to specify the destination directory so that we can add all the files that need to be moved at the end of the command (see the + -exec separator). If your mv does not support -t :
find /path/to/photos \( -iname '*.jpg' -o -iname '*.png' \) -type f -exec mv -nv -- {} '/path/to/master' \;
but it will be less efficient since one instance of mv will be created for each file.
Btw, this moves the files, they do not copy them.
Notes.
- The directory
/path/to/master must already exist (it will not be created with this command). - Make sure the
/path/to/master directory is not in /path/to/photos . That would make this thing awkward!
source share