ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Willy Dufour on April 11, 2019, 01:43:48 PM

Title: How to concatenate directory and filename in IPTC field with "Exiftool-shortcut"
Post by: Willy Dufour on April 11, 2019, 01:43:48 PM
Hello,
I want on source files (raw) write in the tag [IPTC:Source] "the directory" and "file name" with a shortcut "Exiftool".
(example of final data "FileAdress\FileName.raw")
I have the solution for separate fields [...\exiftool.exe -k -IPTC:Source<Directory -L] and [...\exiftool.exe -k -IPTC:Source<FileName -L], but not concatenating them.
What is the code to concatenate these two fields (directory and file name)?
Thanks a lot for your help.
Willy
Title: Re: How to concatenate directory and filename in IPTC field with "Exiftool-shortcut"
Post by: StarGeek on April 11, 2019, 01:55:48 PM
Try
exiftool.exe "-IPTC:Source<$Directory\$Filename" -L
Title: Re: How to concatenate directory and filename in IPTC field with "Exiftool-shortcut"
Post by: Willy Dufour on April 12, 2019, 03:55:31 PM
Hello,
I had already tested your code without success.
With your code, in the field "IPTC: Source" I have the directory without the file name [... / 2019 / 2019-03-24_D500].
(my test file name is "DSC_0010.NEF")
Best regards,
Willy
Title: Re: How to concatenate directory and filename in IPTC field with "Exiftool-shortcut"
Post by: StarGeek on April 12, 2019, 06:22:27 PM
Can you copy/paste the full command and results here? In the CMD window you can drag to select and then hit enter to copy to the clipboard. Paste it using the CODE button above (https://exiftool.org/forum/Themes/default/images/bbc/code.gif) 

Here is my result.  The backslash might be changed to a forward slash for consistancy.
C:\>exiftool -P -overwrite_original "-IPTC:Source<$Directory\$Filename" -L y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -g1 -a -s -IPTC:Source y:\!temp\Test4.jpg
---- IPTC ----
Source                          : y:/!temp\Test4.jpg


Another option might be to use the FilePath tag instead, though that will output the full filepath even in cases you want only part.
C:\>exiftool -P -overwrite_original "-IPTC:Source<Filepath" -L y:\!temp\Test4.jpg
    1 image files updated

C:\Programs\My_Stuff>exiftool -g1 -a -s -IPTC:Source y:\!temp\Test4.jpg
---- IPTC ----
Source                          : y:/!temp/Test4.jpg

Title: Re: How to concatenate directory and filename in IPTC field with "Exiftool-shortcut"
Post by: Willy Dufour on April 13, 2019, 04:39:30 AM
Hello,
Solution solved, thank you for your help.
Sorry (basic lack of computer vision), it was a problem of field length "IPTC: Source" = string [0,32]
By changing the tag "IPTC: SubjectReference" = string [13,236]+, the problem is solved.
With the code [... \ exiftool.exe "-IPTC: SubjectReference <$ Filepath" -L], the result is [directory\filename].
Next time, I will be attentive to this parameter.
My greetings
Willy
:) ;)
Title: Re: How to concatenate directory and filename in IPTC field with "Exiftool-shortcut"
Post by: StarGeek on April 13, 2019, 11:30:20 AM
Ah, my apologies for forgetting about that limitation.

You can override that by adding the -m (ignoreMinorErrors) option (https://exiftool.org/exiftool_pod.html#m--ignoreMinorErrors) to write a string of any length to IPTC:Source.  Another option would be to write to XMP:Source, which can accept long strings, if your software supports it.
Title: Re: How to concatenate directory and filename in IPTC field with "Exiftool-shortcut"
Post by: Willy Dufour on April 16, 2019, 03:02:31 AM
Hello,
Thank you for this detail "-m".
I prefer the tag [IPTC:Source] to [IPTC:SubjectReference], more visible on my software:
The tag [IPTC:SubjectReference] is visible in "ViewNX-i ver.1.3.2" (Nikon), "Gimp ver.1.10.8" and "XnViewMP ver.0.93.1".
The tag [IPTC:Source] is visible in "ViewNX-i ver.1.3.2"(Nikon), "Gimp ver.1.10.8", "XnViewMP ver.0.93.1" (64bits), "Lightroom ver.6.14" (Camera Raw 10.1) and RawTherapee ver.5.5" (32 characters).
Greetings,
Willy