Skip to content

Instantly share code, notes, and snippets.

@mreinstein
Last active May 16, 2022 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mreinstein/36727b1d85c6f233557ae5e90301aa51 to your computer and use it in GitHub Desktop.
Save mreinstein/36727b1d85c6f233557ae5e90301aa51 to your computer and use it in GitHub Desktop.
script to consolidate and clean up media on my computer

media-consolidator

script to consolidate and clean up media on my computer

# copy all known places where photos exist to input/
# preserve metadata when doing the copy (modification timestamps, etc.)
cp -rp ~/Pictures/* input/
cp -rp ~/Documents/Photos/* input/ 

# detect and remove duplicate files within input/
npx duplicate-files-fast --directory ./input --extensions jpg,jpeg,JPG,heic,HEIC,mp4,MP4,mov,MOV,png,PNG --remove

# if you want to do a dry run, use this line instead, which prints out files that will be removed
#npx duplicate-files-fast --directory ./input --extensions jpg,jpeg,JPG,heic,HEIC,mp4,MP4,mov,MOV,png,PNG --remove --dryrun

# move all found media files to output directory (/Volumes/photos)

find input -iname \*.jpg -exec cp -p {} /Volumes/photos \;
find input -iname \*.jpeg -exec cp -p {} /Volumes/photos \;
find input -iname \*.JPG -exec cp -p {} /Volumes/photos \;
find input -iname \*.heic -exec cp -p {} /Volumes/photos \;
find input -iname \*.HEIC -exec cp -p {} /Volumes/photos \;
find input -iname \*.png -exec cp -p {} /Volumes/photos \;
find input -iname \*.PNG -exec cp -p {} /Volumes/photos \;
find input -iname \*.mp4 -exec cp -p {} /Volumes/photos \;
find input -iname \*.MP4 -exec cp -p {} /Volumes/photos \;
find input -iname \*.mov -exec cp -p {} /Volumes/photos \;
find input -iname \*.MOV -exec cp -p {} /Volumes/photos \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment