Author Topic: Special form of %-c  (Read 400 times)

vicmarto

  • Jr. Member
  • **
  • Posts: 27
Special form of %-c
« on: February 25, 2019, 09:40:18 PM »
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

  • Jr. Member
  • **
  • Posts: 27
Re: Special form of %-c
« Reply #1 on: February 25, 2019, 10:21:55 PM »
Found this answer from 2010 about the same topic in forum: http://u88.n24.queensu.ca/exiftool/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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14425
    • ExifTool Home Page
Re: Special form of %-c
« Reply #2 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
...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 ($).

vicmarto

  • Jr. Member
  • **
  • Posts: 27
Re: Special form of %-c
« Reply #3 on: February 26, 2019, 07:04:58 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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14425
    • ExifTool Home Page
Re: Special form of %-c
« Reply #4 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
...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

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2368
Re: Special form of %-c
« Reply #5 on: February 26, 2019, 11:27:08 AM »
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.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

vicmarto

  • Jr. Member
  • **
  • Posts: 27
Re: Special form of %-c
« Reply #6 on: February 27, 2019, 01:39:42 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:


Code: [Select]
$ 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

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2368
Re: Special form of %-c
« Reply #7 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
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

vicmarto

  • Jr. Member
  • **
  • Posts: 27
Re: Special form of %-c
« Reply #8 on: February 27, 2019, 01:50:39 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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14425
    • ExifTool Home Page
Re: Special form of %-c
« Reply #9 on: February 27, 2019, 06:58:28 AM »
Common Mistake #5c strikes even the best of us. ;)

:P

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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

vicmarto

  • Jr. Member
  • **
  • Posts: 27
Re: Special form of %-c
« Reply #10 on: February 27, 2019, 09:52:00 AM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14425
    • ExifTool Home Page
Re: Special form of %-c
« Reply #11 on: February 27, 2019, 09:53:35 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

vicmarto

  • Jr. Member
  • **
  • Posts: 27
Re: Special form of %-c
« Reply #12 on: February 27, 2019, 09:56:03 AM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14425
    • ExifTool Home Page
Re: Special form of %-c
« Reply #13 on: February 27, 2019, 09:57:36 AM »
What was the command you tried?
...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 ($).

vicmarto

  • Jr. Member
  • **
  • Posts: 27
Re: Special form of %-c
« Reply #14 on: February 27, 2019, 09:59:57 AM »
Code: [Select]
$ 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