Salut ça t'intéresse toujours ?
J'ai écrit un petit script pour moi a la base pour continuer a garder la structure.
Les photos sont classé dans des dossiers de cette manière:
ANNéE/MOIS/ANNéE_MOIS_JOUR/ANNéEMOISJOUR_NUMERO.jpg
le script ne s'exécute qu'en console, il n'est pas configurable, et toutes les photos à partir du dossier courant sont traité sous dossiers inclu.
Par exemple pour des fichiers suivant
img/foo/img10.jpg #fait le 16/07/2008
img/foo/img11.jpg #fait le 16/07/2008
bar/img10.jpg #fait le 17/07/2008
Si on lance le script a partir de img/ alors après exécution les fichiers seront déplacé de cette manière:
img/2008/07/2008_07_16/20080716_1.jpg #correspond a img10.jpg du 16/07
img/2008/07/2008_07_16/20080716_2.jpg #correspond a img11.jpg du 16/07
img/2008/07/2008_07_17/20080717_1.jpg #correspond a img10.jpg du 17/07
Il est possible de rajouter les heuresMinutesSecondes de la prise de vue au nom du fichier en exécutant le script de cette manière :
./exifRename.sh YYYYDDMMHHmmSS
Le temps utilisé est la date original de la prise de vue
La date des fichiers est modifié pour correspondre a la prise de vue mais pas la date des dossiers (pas utile à mon sens)
Donc le script :
#!/bin/bash
## Copyright (C) 2008 Petit Aymeric
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License along
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#Initialising some variable
MKDIR="mkdir"
MV="mv"
count=0
fileErr=0
echo -n "Creating file list ... "
find -P . -xdev -iname "*.jpg" -fprintf /tmp/unsortedList "%p\n" 2>/dev/null
sort < /tmp/unsortedList > /tmp/list
#Used only for show progress
numberOfLine=$(wc -l < /tmp/list)
echo "done, $numberOfLine file(s) !"
echo "Starting ..."
while read line
do
#for show progress
let "count = count + 1"
#reading original time of picture (if exist)
exif=$(exif -t0x9003 -m "$line" 2>/dev/null)
if [ x$? != "x0" ] ; then
echo -e "File:$line \t!NOEXIF! \t"
let "fileErr = fileErr + 1"
else
#changed dateTime to an value useable by awk (space and not :)
#even if : can be used by awk. it's more easy
dateTime=$(echo $exif |sed -e"s/:/ /g")
number=1
#Full directory structure
newDirectory=$(echo $dateTime | awk '{print $1"/"$2"/"$1"_"$2"_"$3}')
#creating structure directory
$MKDIR -p $(echo $dateTime | awk '{print $1}')
$MKDIR -p $(echo $dateTime | awk '{print $1"/"$2}')
$MKDIR -p $newDirectory
#Creating touchTime
touchTime=$(echo "$dateTime" | awk '{print $1$2$3$4$5"."$6}')
#Changing time format for the renaming
if [ x"$1" == "xYYYYMMDDHHmmSS" ] ; then
dateTime=$(echo $dateTime | awk '{print $1$2$3$4$5$6}')
else
dateTime=$(echo $dateTime | awk '{print $1$2$3}')
fi
newName="${newDirectory}/${dateTime}_${number}.jpg"
#checking if file exist
while [ -f "$newName" ]
do
#and changing the name
let "number = number + 1"
newName="${newDirectory}/${dateTime}_${number}.jpg"
done
#Yeah ! Changing the name
$MV -i "$line" "$newName"
touch -t $touchTime "$newName"
echo -ne "File:$line \trenamed:$newName \t"
fi
#the stats
echo "[$count/$numberOfLine]"
#a method to input a file for read who read a line .. crazy !
done < /tmp/list
#litle end
echo -e "\ndone ! $fileErr file with no exif date"
Pensez à faire un chmod +x exifRename.sh