[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Script pour renommer des photos selon la date de leur prise



François Cerbelle a écrit, vendredi 30 janvier 2009, à 15:59 :
> David Cure a écrit :
>> Le Fri, Jan 30, 2009 at 03:30:51PM +0100, Guillaume ecrivait :
>>> Qui saurait me dire comment faire la (lourde) tâche suivante ?
>> [snip] 
>>> Ben, il faudrait pouvoir pousser le vice à ajouter l'heure de prise, 
>>> du genre 08_03_30_15h24.jpg 
>>>
>>> Quelqu'un aurait-il l'esprit suffisamment tordu pour m'aider ?
>>
>> 	même pas besoin de l'esprit tordu : jhead fait ça très bien.

Oui, mais les renommages sont limités à l'aspect date.

> Si j'avais su plus tôt...
> J'ai plusieurs fois installé le paquet exif et construit une commande du  
> genre :
> for i in *.JPG; do mv "$i" "`exif -i "$i" | grep 9003 | cut -d\| -f2 |  
> cut -d\  -f1-2 | sed 's/://g;s/ /_/'`-`echo $i | sed  
> 's/IMG.//;s/.JPG/.jpg/'`";done;
>
> Comme ca, il y a la date, l'heure et le numero de sequence.
> C'est du (moyen)quick-and-(very)dirty, mais ca marche à condition  
> d'avoir le paquet exif

On doit pouvoir simplifier ;) --- mais exiftool offre plus de souplesse

,----(man exiftool, -> RENAMING EXAMPLES)
|
| exiftool '-Directory<DateTimeOriginal' -d %Y/%m/%d dir
|      Move all  files in  "dir" into a  directory hierarchy  based on
|      year, month  and day  of "DateTimeOriginal".  ie)  This command
|      would move  the file "dir/image.jpg"  with a "DateTimeOriginal"
|      of "2005:10:12 16:05:56" to "2005/10/12/image.jpg".
|
| exiftool '-filename<%f_${focallength}.%e' dir
|      Rename all  files in  "dir" by adding  FocalLength to  the file
|      name.
|
| exiftool '-FileName<CreateDate' -d %Y%m%d_%H%M%S.%%e dir
|      Rename all  images in "dir" according to  the "CreateDate" date
|      and time,  preserving the  original file extensions.   Note the
|      extra '%'  added to the file  extension code (%%e)  since it is
|      used in a date format string.
|
| exiftool -r '-FileName<CreateDate' -d %Y-%m-%d/%H%M_%%f.%%e dir
|      Both the directory and the filename may be changed together via
|      the "FileName" tag  if the new "FileName" contains  a '/'.  The
|      example above recursively renames  all images in a directory by
|      adding a  "CreateDate" timestamp to the start  of the filename,
|      then moves them into new directories named by date.
|
| exiftool    '-FileName<${CreateDate}_$filenumber.jpg'    -d   %Y%m%d
| dir/*.jpg
|      Set the  filename of  all JPG images  in the  current directory
|      from  the   CreateDate  and   FileNumber  tags,  in   the  form
|      "20060507_118-1861.jpg".
|
`----

Par ailleurs, j'utilise le script gpsPhoto.pl pour créer les champs GPS,
je vais donc sans doute pouvoir intégrer tout ça en Perl...
-- 
Jacques L'helgoualc'h


Reply to: