Created
February 5, 2018 10:35
-
-
Save janssens/81ccf566d12c8af26e23bfe3633c739f to your computer and use it in GitHub Desktop.
File jpeg files in sub dir from name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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