Skip to content

Instantly share code, notes, and snippets.

@matissime
Created January 31, 2023 18:06
Show Gist options
  • Save matissime/7ad2a75747d3ba45a6de91f8d14ea27b to your computer and use it in GitHub Desktop.
Save matissime/7ad2a75747d3ba45a6de91f8d14ea27b to your computer and use it in GitHub Desktop.
This little bash script is useful to manage and sort photo in bulk, once you deleted all the unwanted JPEG image, run the script in the folder to delete all the corresponding raw file
#!/bin/bash
mkdir unwanted #create a directory to store unwanted file
for file in *.NEF; do #for each .NEF find a .JPG file that as the same name
jpg_file="${file%.*}.JPG"
if [ ! -e "$jpg_file" ]; then #if a .NEF does not have a corresponding .JPEG file, move the .NEF file in the folder
mv "$file" ./unwanted/"$file"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment