Skip to content

Instantly share code, notes, and snippets.

@afischer
Created December 17, 2017 21:04
Show Gist options
  • Save afischer/9788a4126f2a76f46ae692a65bf3e0c0 to your computer and use it in GitHub Desktop.
Save afischer/9788a4126f2a76f46ae692a65bf3e0c0 to your computer and use it in GitHub Desktop.
Bash script to move date-prefixed/count-suffixed photos into folders
find -E . -regex '\.\/[0-9]{8}_.*' | while read filename
do
strippedindex=$(expr "$filename" : "\.\/[0-9]*_[a-zA-Z0-9]*")
strippedname=${filename:2:strippedindex-2}
mkdir -p "$strippedname"
mv "$filename" "$strippedname"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment