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

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14438
    • ExifTool Home Page
Re: Special form of %-c
« Reply #15 on: February 27, 2019, 10:00:49 AM »
I meant the one that didn't work.
...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 #16 on: February 27, 2019, 10:07:15 AM »
This is my code, of course don't work  ;D

Code: [Select]
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' \
-execute \
-ext 'arw' -ext 'dng' -ext 'jpg' -ext 'jpeg' -ext 'nef' -ext 'tif' -ext 'tiff' -ext 'png' -ext 'avi' -ext 'mov' -ext 'mp4' \
exiftool "-filename=%-.2f-0.%e" -srcfile %d%-.2f.%e ./*-1.jpg
-common_args -r -overwrite_original \
.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14438
    • ExifTool Home Page
Re: Special form of %-c
« Reply #17 on: February 27, 2019, 10:12:21 AM »
Two problems.

1. You added an "exiftool" that shouldn't be there.

2. You want to process different directories with this command, so the -common_args don't apply.

Try this:

Code: [Select]
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}' \
-r -overwrite_original . -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}' \
-r -overwrite_original . -execute \
-d '%Y-%m-%d %H.%M.%S' -ext 'avi' \
-api largefilesupport=1 '-FileName<${DateTimeOriginal}%-c.${FileTypeExtension}' \
-r -overwrite_original . -execute \
-d '%Y-%m-%d %H.%M.%S' -ext 'mov' -ext 'mp4' \
-api largefilesupport=1 '-FileName<${CreateDate}%-c.${FileTypeExtension}' '-FileName<${CreationDate}%-c.${FileTypeExtension}' \
-r -overwrite_original . -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' \
-r -overwrite_original . -execute \
-ext 'arw' -ext 'dng' -ext 'jpg' -ext 'jpeg' -ext 'nef' -ext 'tif' -ext 'tiff' -ext 'png' -ext 'avi' -ext 'mov' -ext 'mp4' \
"-filename=%-.2f-0.%e" -srcfile %d%-.2f.%e ./*-1.*

- 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 #18 on: February 27, 2019, 10:39:47 AM »
Thanks Phil, your code is working perfectly, but only in .. When I try to hardcode a path in the -d option (for using the code in a shell script), two problems arise:

1.-   The code to sync the FileName to the FileModifyDate, breaks
2.-   Error: File not found - ./*-1.*, the rename breaks as well


This is the code I used, modified my me:
Code: [Select]
exiftool \
-d '/Users/user/Pictures/%Y/%m/%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}' \
-r -overwrite_original /Users/user/Pictures/@input -execute \
-d '/Users/user/Pictures/Screenshots/%Y/%m/%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}' \
-r -overwrite_original /Users/user/Pictures/@input -execute \
-d '/Users/user/Pictures/%Y/%m/%Y-%m-%d %H.%M.%S' -ext 'avi' \
-api largefilesupport=1 '-FileName<${DateTimeOriginal}%-c.${FileTypeExtension}' \
-r -overwrite_original /Users/user/Pictures/@input -execute \
-d '/Users/user/Pictures/%Y/%m/%Y-%m-%d %H.%M.%S' -ext 'mov' -ext 'mp4' \
-api largefilesupport=1 '-FileName<${CreateDate}%-c.${FileTypeExtension}' '-FileName<${CreationDate}%-c.${FileTypeExtension}' \
-r -overwrite_original /Users/user/Pictures/@input -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' \
-r -overwrite_original /Users/user/Pictures/@input -execute \
-ext 'arw' -ext 'dng' -ext 'jpg' -ext 'jpeg' -ext 'nef' -ext 'tif' -ext 'tiff' -ext 'png' -ext 'avi' -ext 'mov' -ext 'mp4' \
"-filename=%-.2f-0.%e" -srcfile %d%-.2f.%e ./*-1.*

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14438
    • ExifTool Home Page
Re: Special form of %-c
« Reply #19 on: February 27, 2019, 10:47:01 AM »
The "./*-1.*" won't work after you have moved the files to "/mnt/zfast/Users/vicmarto/Pictures/Fototeca/%Y/%m/".

Unfortunately this is complicated because you have %Y/%m in the directory name.  You could change "./*-1.*" to this:

"/mnt/zfast/Users/vicmarto/Pictures/Fototeca/*/*/*-1.*"

But that would unnecessarily scan all of your pictures, and not only the ones that you have just renamed.

I can't think of a good way around this.

- 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 #20 on: February 27, 2019, 10:59:28 AM »
I see now where is the problem, well don't worry, thank you very much anyway for your patience   ;)

About the other problem? It's possible to make the "code to sync the FileName to the FileModifyDate" work when an output directory is hardcoded into the -d option?

-d '/Users/user/Pictures/%Y/%m/%Y-%m-%d %H.%M.%S'

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14438
    • ExifTool Home Page
Re: Special form of %-c
« Reply #21 on: February 27, 2019, 11:05:20 AM »
Hardcoded is fine, but %Y/%m is not hard coded... it uses whatever date/time is contained in the file.  I already provided the only work-around I can think of for this case.

- 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 #22 on: February 28, 2019, 06:05:29 AM »
Hardcoded is fine, but %Y/%m is not hard coded... it uses whatever date/time is contained in the file.  I already provided the only work-around I can think of for this case.

- Phil

Ok... I see now where is the problem. A big thanks fo you and StarGeek!!
I want from here to recommend ExifTool to everyone, regardless of the workflow you use, or the photo management software you use: ExifTool is perfect for you. To ordering, importing and renaming photos. It is very flexible and powerful, and the support is top notch !!