News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Special form of %-c

Started by vicmarto, February 25, 2019, 09:40:18 PM

Previous topic - Next topic

vicmarto

Hello!

I want to use %-c to couple with burst shot camera, but adding it to all shots that share the same second. For example, using:

$ exiftool -d '%Y-%m-%d %H.%M.%S' '-FileName<${DateTimeOriginal}%-c.${FileTypeExtension}' . I'm getting:

2010-10-16 10.54.53.jpg ---> left unchanged
2010-10-16 10.53.58.jpg ---> left unchanged
2010-10-16 10.54.03.jpg ---> left unchanged
2010-10-16 10.54.43.jpg ---> left unchanged
2010-10-16 10.54.48-1.jpg ---> ok
2010-10-16 10.54.48.jpg ---> Change to 2010-10-16 10.54.48-0.jpg

How can I change 2010-10-16 10.54.48.jpg to 2010-10-16 10.54.48-0.jpg maintaining the non burst shots as is, without adding too -0.jpg?

Thanks in advance!!

vicmarto

Found this answer from 2010 about the same topic in forum: https://exiftool.org/forum/index.php/topic,2746.msg12142.html#msg12142

Maybe this still can't be done with a current version of ExifTool? Please, confirm.

Phil Harvey

Anything you could do with older versions of ExifTool you can still do with newer versions (with very rare exceptions).

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

vicmarto

Quote from: Phil Harvey on February 26, 2019, 06:59:51 AM
Anything you could do with older versions of ExifTool you can still do with newer versions (with very rare exceptions).

- Phil

Well, I was asking about the opposite, sorry  ;D With the old version was not possible, maybe now is possible?

Phil Harvey

Oh, I see.

Is it only "-0" that you want to add if the "-1" file exists?  If so, this will do it:

exiftool "-filename<%-.2f-0.%e" -srcfile %d%-.2f.%e DIR/*-1.jpg

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

StarGeek

I think that the question is whether %c can be used to add -0 only when there is going to be a duplicate name.  So given the examples, the results should be
2010-10-16 10.54.43.jpg
2010-10-16 10.54.48-0.jpg
2010-10-16 10.54.48-1.jpg
2010-10-16 10.54.50.jpg

on the first pass.  Which I don't believe have changed since the 2010 post linked since there hasn't been any changes to the docs (see -w (textout) option).  Though it's cool that you came up with a workaround.

Myself, I just switched to using an underscore instead of a dash to keep file order sorted properly.
* 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).

vicmarto

Quote from: Phil Harvey on February 26, 2019, 07:32:28 AM
Oh, I see.

Is it only "-0" that you want to add if the "-1" file exists?  If so, this will do it:

exiftool "-filename<%-.2f-0.%e" -srcfile %d%-.2f.%e DIR/*-1.jpg

- Phil

Thanks Phil for your answer. Unfortunately, I'm having a hard time getting it to work, thanks for your patience. I'm sure I'm doing something wrong:


$ ls -l
-rw-r--r--  1 user  group   1107409 27 dic  2002 2002-12-27 22.14.32-1.jpg
-rw-r--r--  1 user  group   1107409 27 dic  2002 2002-12-27 22.14.32.jpg
-rw-r--r--  1 user  group  27321426 16 oct  2010 2010-10-16 12.44.02-1.dng
-rw-r--r--  1 user  group  27321426 16 oct  2010 2010-10-16 12.44.02.dng
-rw-r--r--  1 user  group   4172842 16 oct  2010 2010-10-16 12.49.35.jpg

$ exiftool '-FileName<%-.2f-0.%e' -srcfile %d%-.2f.%e ./*-1.*
Warning: No writable tags set from ./2002-12-27 22.14.32-1.jpg
Warning: Invalid tag name '%-.2f-0.%e' - ./2002-12-27 22.14.32.jpg
Warning: No writable tags set from ./2010-10-16 12.44.02-1.dng
Warning: Invalid tag name '%-.2f-0.%e' - ./2010-10-16 12.44.02.dng
    0 image files updated
    2 image files unchanged


I'm expecting that 2002-12-27 22.14.32.jpg renames to 2002-12-27 22.14.32-0.jpg, that 2010-10-16 12.44.02.dng renames to 2010-10-16 12.44.02-0.dng, and that 2010-10-16 12.49.35.jpg remains unrenamed.

And... I don't know how can I integrate your answer to my currently using ExifTool order, one more -execute maybe?:

exiftool \
-d '%Y-%m-%d %H.%M.%S' -ext 'arw' -ext 'dng' -ext 'jpg' -ext 'jpeg' -ext 'nef' -ext 'tif' -ext 'tiff' -IPTC:all= -XMP:all= -Photoshop:all= \
'-FileName<${FileModifyDate}%-c.${FileTypeExtension}' '-FileName<${MetadataDate}%-c.${FileTypeExtension}' \
'-FileName<${ModifyDate}%-c.${FileTypeExtension}' '-FileName<${CreateDate}%-c.${FileTypeExtension}' '-FileName<${DateTimeOriginal}%-c.${FileTypeExtension}' \
'-FileName<${ModifyDate}.${SubSecTime;$_=substr($_.'0',0,2)}.${FileTypeExtension}' \
'-FileName<${CreateDate}.${SubSecTimeDigitized;$_=substr($_.'0',0,2)}.${FileTypeExtension}' \
'-FileName<${DateTimeOriginal}.${SubSecTimeOriginal;$_=substr($_.'0',0,2)}.${FileTypeExtension}' \
-execute \
-d '%Y-%m-%d %H.%M.%S' -ext 'png' -IPTC:all= -XMP:all= -Photoshop:all= \
'-FileName<${FileModifyDate}%-c.${FileTypeExtension}' '-FileName<${MetadataDate}%-c.${FileTypeExtension}' '-FileName<${DateCreated}%-c.${FileTypeExtension}' \
-execute \
-d '%Y-%m-%d %H.%M.%S' -ext 'avi' \
-api largefilesupport=1 '-FileName<${DateTimeOriginal}%-c.${FileTypeExtension}' \
-execute \
-d '%Y-%m-%d %H.%M.%S' -ext 'mov' -ext 'mp4' \
-api largefilesupport=1 '-FileName<${CreateDate}%-c.${FileTypeExtension}' '-FileName<${CreationDate}%-c.${FileTypeExtension}' \
-execute \
-ext 'arw' -ext 'dng' -ext 'jpg' -ext 'jpeg' -ext 'nef' -ext 'tif' -ext 'tiff' -ext 'png' -ext 'avi' -ext 'mov' -ext 'mp4' \
-if '${FileModifyDate;tr/0-9//cd;s/^(\d{14}).*/$1/} ne ${FileName;tr/0-9//cd;s/^(\d{14}).*/$1/}' '-FileModifyDate<FileName' \
-common_args -r -overwrite_original \
.


Thanks in advance!

StarGeek

Common Mistake #5c strikes even the best of us. ;)

Equal sign instead of Less than sign

exiftool "-filename=%-.2f-0.%e" -srcfile %d%-.2f.%e DIR/*-1.jpg
* 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).

vicmarto

Quote from: StarGeek on February 27, 2019, 01:46:02 AM
Common Mistake #5c strikes even the best of us. ;)

Equal sign instead of Less than sign

exiftool "-filename=%-.2f-0.%e" -srcfile %d%-.2f.%e DIR/*-1.jpg

Hahahha, thank you very much StarGeek, and sorry for so strange requests  ;D

What about integrating exiftool "-filename=%-.2f-0.%e" -srcfile %d%-.2f.%e DIR/*-1.jpg in my current exiftool order (above)? Can be done? Must exiftool be called two times?

Phil Harvey

Quote from: StarGeek on February 27, 2019, 01:46:02 AM
Common Mistake #5c strikes even the best of us. ;)

:P

Quote from: vicmarto on February 27, 2019, 01:50:39 AM
What about integrating exiftool "-filename=%-.2f-0.%e" -srcfile %d%-.2f.%e DIR/*-1.jpg in my current exiftool order (above)? Can be done? Must exiftool be called two times?

Yes, this requires two commands.  But you can do this with do it with another -execute in your command.
...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 ($).

vicmarto

Sorry Phil, after expending more than two hours trying to integrate it into my command, finally give up. I think the problem is in the DIR/*-1.jpg part. Because I'm getting:

Error: File not found - ./*-1.jpg

I just can't get ExifTool to find the correct file to rename...   :-[

Phil Harvey

Are there any files with names that end in "-1.jpg" in the current directory?  Make sure the "*" is not quoted.  What was your exact command?  What OS are you running?

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

vicmarto

Yes, there are. Your code is correct, it's working, it's just I don't know how to integrate it into my current ExifTool order using another one -execute, this is the problem:

exiftool \
-d '%Y-%m-%d %H.%M.%S' -ext 'arw' -ext 'dng' -ext 'jpg' -ext 'jpeg' -ext 'nef' -ext 'tif' -ext 'tiff' -IPTC:all= -XMP:all= -Photoshop:all= \
'-FileName<${FileModifyDate}%-c.${FileTypeExtension}' '-FileName<${MetadataDate}%-c.${FileTypeExtension}' \
'-FileName<${ModifyDate}%-c.${FileTypeExtension}' '-FileName<${CreateDate}%-c.${FileTypeExtension}' '-FileName<${DateTimeOriginal}%-c.${FileTypeExtension}' \
'-FileName<${ModifyDate}.${SubSecTime;$_=substr($_.'0',0,2)}.${FileTypeExtension}' \
'-FileName<${CreateDate}.${SubSecTimeDigitized;$_=substr($_.'0',0,2)}.${FileTypeExtension}' \
'-FileName<${DateTimeOriginal}.${SubSecTimeOriginal;$_=substr($_.'0',0,2)}.${FileTypeExtension}' \
-execute \
-d '%Y-%m-%d %H.%M.%S' -ext 'png' -IPTC:all= -XMP:all= -Photoshop:all= \
'-FileName<${FileModifyDate}%-c.${FileTypeExtension}' '-FileName<${MetadataDate}%-c.${FileTypeExtension}' '-FileName<${DateCreated}%-c.${FileTypeExtension}' \
-execute \
-d '%Y-%m-%d %H.%M.%S' -ext 'avi' \
-api largefilesupport=1 '-FileName<${DateTimeOriginal}%-c.${FileTypeExtension}' \
-execute \
-d '%Y-%m-%d %H.%M.%S' -ext 'mov' -ext 'mp4' \
-api largefilesupport=1 '-FileName<${CreateDate}%-c.${FileTypeExtension}' '-FileName<${CreationDate}%-c.${FileTypeExtension}' \
-execute \
-ext 'arw' -ext 'dng' -ext 'jpg' -ext 'jpeg' -ext 'nef' -ext 'tif' -ext 'tiff' -ext 'png' -ext 'avi' -ext 'mov' -ext 'mp4' \
-if '${FileModifyDate;tr/0-9//cd;s/^(\d{14}).*/$1/} ne ${FileName;tr/0-9//cd;s/^(\d{14}).*/$1/}' '-FileModifyDate<FileName' \
-common_args -r -overwrite_original \
.

Phil Harvey

What was the command you tried?
...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 ($).

vicmarto

$ ls -l
total 4326
-rw-r--r--  1 user  group  1107409  1 ene  1990 2002-12-27 22.14.32-1.jpg
-rw-r--r--  1 user  group  1107409  1 ene  1990 2002-12-27 22.14.32.jpg

$ exiftool "-filename=%-.2f-0.%e" -srcfile %d%-.2f.%e ./*-1.jpg
    1 image files updated

$ ls -l
total 4326
-rw-r--r--  1 user  group  1107409  1 ene  1990 2002-12-27 22.14.32-0.jpg
-rw-r--r--  1 user  group  1107409  1 ene  1990 2002-12-27 22.14.32-1.jpg