Pour des images, télécharger le paquet jhead puis
for i in $(ls *.jpg); do date=$(jhead $i | grep "File date"); date=${date#*: }; date=${date//:/}; an=${date:0:4}; mois=${date:4:2}; dossier=$an"/"$mois; echo $i" -> "$dossier; mkdir -p $dossier; mv "$i" $dossier; done;
Ou en une ligne :
for i in $(ls *.jpg); do date=$(jhead $i | grep "File date"); date=${date#*: }; date=${date//:/}; an=${date:0:4}; mois=${date:4:2}; dossier=$an"/"$mois; echo $i" -> "$dossier; mkdir -p $dossier; mv "$i" $dossier; done;
Pour des vidéos, installer libimage-exiftool-perl
for i in $(ls *.mp4); do date=$(exiftool $i | grep Modification); date=${date#*: }; date=${date//:/}; date=${date%+*}; an=${date:0:4}; mois=${date:4:2}; dossier=$an"/"$mois; echo $i" -> "$dossier; mkdir -p $dossier; done;
for i in $(ls *.mp4); do date=$(exiftool $i | grep Modification);date=${date#*: }; date=${date//:/}; date=${date%+*}; an=${date:0:4}; mois=${date:4:2}; dossier=$an"/"$mois; echo $i" -> "$dossier; mkdir -p $dossier; done;