filename using multiple assignments

Started by aljr, October 07, 2018, 07:24:36 PM

Previous topic - Next topic

aljr

I'm trying to include subseconds when renaming, if that info exists. And to use CreateDate rather than the invalid DateTimeOriginal if the file is a .MOV file

When I use multiple assignments to cover these scenarios via a single exiftool rename command, every file uses the last assignment, even when all of the tags are invalid in the file being processed. The "earlier", valid filename assignments are never used. My understanding is that exiftool should use the last valid assignment.

I read Phil's comments about using multiple assignments, with the last valid assignment superceding (here):
https://exiftool.org/forum/index.php/topic,5079.msg24483.html#msg24483

And Example 12 of the documentation, regarding the same approach (here):
https://exiftool.org/filename.html

When I use these input files:
$ exiftool -exif:subsectimeoriginal -model -filename -T .

- iPhone 3GS IMG_0972.MOV
- iPhone 4 IMG_2891.JPG
158 iPhone 5s IMG_6179.JPG
312 iPhone 5s IMG_6192 copy 2.JPG
312 iPhone 5s IMG_6192.JPG
491 iPhone 5s IMG_6193.JPG
- iPhone 4 IMG_7218.jpg


And rename using:
$ exiftool -m -P -d '%Y-%m-%d_%H-%M-%S' \
'-testname<${CreateDate}_A_%+3c.%e' \
'-testname<${DateTimeOriginal}_B_%+3c.%e' \
'-testname<${DateTimeOriginal}_C_-${subsectimeoriginal;$_.=0 x(3-length)}%+3c.%e' \
.

   
The results are:

'./IMG_0972.MOV' --> './_C_-.MOV'
'./IMG_2891.JPG' --> './2013-04-09_17-31-32_C_-.JPG'
'./IMG_6179.JPG' --> './2014-01-02_12-23-22_C_-158.JPG'
'./IMG_6192 copy 2.JPG' --> './2014-01-02_12-30-47_C_-312.JPG'
'./IMG_6192.JPG' --> './2014-01-02_12-30-47_C_-312_001.JPG'
'./IMG_6193.JPG' --> './2014-01-02_12-30-48_C_-491.JPG'
'./IMG_7218.jpg' --> './2012-05-06_10-10-36_C_-.jpg'


All of files use the 3rd assignment, even the .MOV and .JPG files with no SubSecTimeOriginal. The .MOV file doesn't have a DateTimeOriginal either, but still uses the 3rd assignment.

I'm using "A", "B", "C" to easily identify which assignment is being used. The extra hyphen at the end of the files with no subsec... tag gives it away also.

Can anyone explain why exiftool isn't using the 1st or 2nd assignment?

Thanks,

Al
exiftool 11.06 on MacOS 10.12.6

StarGeek

I had to dig around a bit to find this post which answers the problem.

Quote from: Phil Harvey on May 31, 2018, 12:21:33 PM
The problem is the -m option, which ignores missing tag values and replaces them with an empty string.

Remove the -m and it should work for you.

Buried deep within the documentation:

            the -m option may be used to ignore minor warnings and leave
            the missing values empty.

If you remove the -m option, it should work.  You don't need to use -m when you're renaming/moving a file anyway.

Phil, maybe a note under -m about leaving values blank with regards to renaming/moving and printFormat (any other situations)?  It's a bit hard to find embedded in the -p docs.
* 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).

aljr

StarGeek,

You're absolutely right. I completely missed that and had started using -m to clean up the output while testing. Thanks!

aljr

Phil Harvey

Quote from: StarGeek on October 07, 2018, 09:20:48 PM
Phil, maybe a note under -m about leaving values blank with regards to renaming/moving and printFormat (any other situations)?

This affects -tagsFromFile, -p and -if strings.  I tried adding something to the -m documentation, but couldn't find any wording I was happy with.  I tried something like this:

Note that this causes missing values in -tagsFromFile,
-p and -if strings to be set to an empty string rather than
an undefined value.


... I don't know if anyone would catch the significance of this.

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

Hayo Baan

Quote from: Phil Harvey on October 08, 2018, 08:39:29 PM
I tried something like this:

Note that this causes missing values in -tagsFromFile,
-p and -if strings to be set to an empty string rather than
an undefined value.


... I don't know if anyone would catch the significance of this.

Looks clear to me and certainly better than not explicitly mentioning this; now people will at least be notified something special is going on ;)
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

OK then, I'll add this to the documentation.

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