Author Topic: File Renaming using dates and replacing text string  (Read 2757 times)

José Oliver-Didier

  • Full Member
  • ***
  • Posts: 31
    • José Oliver-Didier
File Renaming using dates and replacing text string
« on: March 31, 2010, 11:54:18 AM »
Is there any way to rename files using exiftool in this form:

IMG_1234.JPG to 100331-1234.JPG

where the "IMG_" is replaced by YYMMDD

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16883
    • ExifTool Home Page
Re: File Renaming using dates and replacing text string
« Reply #1 on: March 31, 2010, 12:15:24 PM »
Sure, this command will do what you want using the date from DateTimeOriginal:

  exiftool -d %y%m%d-%%-4f.%%e "-filename<datetimeoriginal" -v FILE

where FILE is one or more file or directory names.  The %-4f takes the last 4 characters from the filename (and the extra % is necessary to get this through the date/time parsing).  I also added a -v option for verbose output so you can see what the files get renamed to.  If DateTimeOriginal isn't available, you can use CreateDate, ModifyDate or even FileModifyDate for the source date/time value.

For more information and examples of this feature, see the filename page and the -w option in the exiftool application documentation.

- Phil

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

José Oliver-Didier

  • Full Member
  • ***
  • Posts: 31
    • José Oliver-Didier
Re: File Renaming using dates and replacing text string
« Reply #2 on: April 11, 2010, 04:52:45 PM »
thanks!