Instantly share code, notes, and snippets.

Embed
What would you like to do?
Uno script bash che permette di organizzare un gruppo di immagini in cartelle che ne contengono al massimo 300 cadauna. Vedi post sul blog: https://wp.me/pdQ5q-9UO
#!/bin/bash
# Blocco rename da JPG/JPEG/jpeg a jpg
# Credits: https://www.tldp.org/LDP/GNU-Linux-Tools-Summary/html/x4055.htm
for i in *.JPG;
do mv $i ${i%%.JPG}.jpg;
done
for i in *.JPEG;
do mv $i ${i%%.JPEG}.jpg;
done
for i in *.jpeg;
do mv $i ${i%%.jpeg}.jpg;
done
# Riorganizzo le immagini in cartelle in blocchi da 300 ($c -eq 300)
# Credits: https://unix.stackexchange.com/posts/180105/revisions
c=1; d=1; mkdir -p PICS_${d}
for jpg_file in *.jpg
do
if [ $c -eq 300 ]
then
d=$(( d + 1 )); c=0; mkdir -p PICS_${d}
fi
mv "$jpg_file" PICS_${d}/
c=$(( c + 1 ))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment