Skip to content

Instantly share code, notes, and snippets.

@janssens
Created February 5, 2018 10:35
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 janssens/81ccf566d12c8af26e23bfe3633c739f to your computer and use it in GitHub Desktop.
Save janssens/81ccf566d12c8af26e23bfe3633c739f to your computer and use it in GitHub Desktop.
File jpeg files in sub dir from name
#!/bin/bash
for f in *.jpg
do
y=$( echo $f | sed 's/\([0-9]*\)-\([0-9]*\)-\([0-9]*\)_.*/\1/')
m=$( echo $f | sed 's/\([0-9]*\)-\([0-9]*\)-\([0-9]*\)_.*/\2/')
[ -d $y ] || mkdir $y
[ -d "$y/$m" ] || mkdir "$y/$m"
mv $f "./$y/$m"
echo "$f moved to $y/$m"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment