Author Topic: how to use tag $model in filename and directory name?  (Read 1461 times)

liwa

  • Newbie
  • *
  • Posts: 3
how to use tag $model in filename and directory name?
« on: December 23, 2012, 08:41:57 PM »
Hi
I'm trying
 1- to rename by model and datetimeoriginal
 2- to sort by model and year
like that
Code: [Select]
MX-700
 1999
   1999-01-02
     MX-700-1999-01-01 17-05-12 DSC0115.JPG
former Fujifilm MX700 :)


The command
 "d:\Portable apps\exiftools\exiftool.exe" -r  "-Filename<$model $DateTimeOriginal" -d "%Y-%m-%d\%Y-%m-%d %H-%M-%S %%f.%%e" dir
give :
Code: [Select]
MX-700 1999-01-02
 1999-01-01 17-05-12 DSC0115.JPG

The command
  "d:\Portable apps\exiftools\exiftool.exe" -r  "-Filename<$model\$DateTimeOriginal" -d "%Y-%m-%d\%Y-%m-%d %H-%M-%S %%f.%%e" dir
give
Code: [Select]
MX-700
 1999-01-02
     1999-01-01 17-05-12 DSC0115.JPG
that's nice but I don't understand how it works
and I would like to include the tag "model" in the filename not only the directory name


How to rename file as  MX-700-1999-01-01 17-05-12 DSC0115.JPG
Why option -o is impossible in each command above?
How to do the same in one path?

I don't understand the correct way to use $model

Thank you very much

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 13735
    • ExifTool Home Page
Re: how to use tag $model in filename and directory name?
« Reply #1 on: December 24, 2012, 07:35:16 AM »
This is closer:

"d:\Portable apps\exiftools\exiftool.exe" -r  "-Filename<$model\$DateTimeOriginal" -d "%Y\%Y-%m-%d\%Y-%m-%d %H-%M-%S %%f.%%e" dir

and gives

Code: [Select]
MX-700
 1999
   1999-01-02
      1999-01-01 17-05-12 DSC0115.JPG

But adding the model name to the file name is tricky.  The easiest way is to do it with a second command:

"d:\Portable apps\exiftools\exiftool.exe" -r  "-Filename<$model-%f.%e" -if "$filename !~ /^$model/" .

This will add the model name to any file that doesn't already start with the model name.

There is a way to do this in a single step, but it is a bit more complicated because it requires creating a user-defined tag.

- 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 ($).