Renaming syntax?

Started by Beholder3, October 17, 2021, 10:30:40 AM

Previous topic - Next topic

Beholder3

Hi,I think I can already do a lot with exiftool, but I completely fail with simple file renaming. When I google some reference questions I always think I understand how to do it, but once I change a single letter, it fails.
I do all this on a windows machine.
Here are some of the things I want to do:

       
  • MP4 video files to be named like "2021-10-31 Birthday 001" (capture date, free text, numbering starting with 001)
  • MP4 video files to be named like "2021-10-31 Birthday 001" (where "2021-10-31 Birthday" is the foldername, numbering starting with 001)
  • CR3 files to be named like "Sigma 35mm F1,4 DG HSM Art F5.6 001" (lens, aperture, number starting with 001)
  • Always with those spaces in between, extension stays the same.
In some cases I even get some folders created where I did not intend to.
I tried something like-filename<"$focallength F$FNumber $LensModel.%e"which did not work.
I tried this here as a starting point, but once I changed something it was a mess:-FileName<${CreateDate} -d %Y%m%d%%-.3nc.%%leSo there is something in the syntax which I completely fail to understand.
Any help appreciated.  :)

Phil Harvey

You will get unexpected folders any time you write a "/" in a file name (ie. "Sigma 35mm f/1.4" will create a directory called "Sigma 25mm f").  To avoid this, use ${lensmodel;} instead of $lensmodel in your format string -- this will filter out all characters that are illegal in file names.

I suggest writing TestName instead of FileName to start, until you get what you want.

I don't understand your points 1 and 2.  What is the difference?

Quote from: Beholder3 on October 17, 2021, 10:30:40 AM
-FileName<${CreateDate} -d %Y%m%d%%-.3nc.%%le

You need quotes around any argument containing a special character such as "<".  These characters are treated differently by the Windows shell.

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

Beholder3

fyi, Im am still using the old exiftoolGUI on windows.

I can use-FileName<${CreateDate} -d %Y%m%d%%-.3nc.%%le and it works.I can also put it in quotes as-FileName<"${CreateDate} -d %Y%m%d%%-.3nc.%%le"and it will still work.
But once I do insert anything new, it fails with
QuoteError creating directory 2021:10:15 17:20:32+02:00 -d %Y%m.
Warning: New file name not allowed in Windows (contains ':')

And I really have no clue where the ":" suddenly come from.

On a positive side I got
-filename<"$focallength F$FNumber ${lensmodel;} %.3nc.%e"
to work well now thanks to your tip.


Phil Harvey

Quote from: Beholder3 on October 18, 2021, 09:49:48 AM
Error creating directory 2021:10:15 17:20:32+02:00 -d %Y%m.
Warning: New file name not allowed in Windows (contains ':')

The -d option is being written as part of the file name instead of being interpreted as an ExifTool option.  I understand this when you put quotes around the whole thing, but don't know why this would happen if it isn't quoted.  I don't know how the quoting works in the GUI.

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

StarGeek

Quote from: Beholder3 on October 18, 2021, 09:49:48 AM
I can also put it in quotes as
-FileName<"${CreateDate} -d %Y%m%d%%-.3nc.%%le"
and it will still work.

As written, this should not work.  This is treating everything between the quotes as a single command and you're atteming to write
-d %Y%m%d%%-.3nc.%%le
as part of the file name, not trying to use the -d option.  This would keep the colons that are part off CreateDate.

Separate arguments cannot be within the same quotes.  For example, you could not use this
"-d %Y%m%d%%-.3nc.%%le"
as that treats the entire thing as a single option named "d %Y%m%d%%-.3nc.%%le", spaces included.

But you could do this
"-d" "%Y%m%d%%-.3nc.%%le"
as each is a separate item, the first is the exiftool option and the second is the parameters of that option.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).