problem with command Set Title field from substring of filename

Started by groofie, January 10, 2024, 06:00:52 AM

Previous topic - Next topic

groofie

I'am using Win 11
and exiftool 12.72

The goal is to replace the ImageDescription with a substring of the filename

I searched on google and found

https://exiftool.org/forum/index.php?topic=9922.0
    exiftool "-title<${filename;$_=substr($_,4,3).' '.substr($_,7,5)}" DIR

https://exiftool.org/forum/index.php?topic=4779.0
    "-title<${filename;s/^.{11}(.*)\..*$/$1/}"
    another way (using substr) would have been:
    "-title<${filename;$_=substr($_,11);s/\.[^.]*$//}"

This is my commandprompt in windows

D:\__OurProgs\exiftool\exiftool -ImageDescription<${filename;s/^.{11}(.*)\..*$/$1/} -overwrite_original -r -m -F "D:\____Bewerken\Foto"
And also

D:\__OurProgs\exiftool\exiftool -ImageDescription<${filename;$_=substr($_,11);s/\.[^.]*$//}" -overwrite_original -r -m -F "D:\____Bewerken\Foto"
But i alway's receive the warning
Warning: Error opening file - ZgBpAGwAZQBuAGEAbQBlADsAJABfAD0AcwB1AGIAcwB0AHIAKAAkAF8ALAA0ACwAMwApAC4AJwAgACcALgBzAHUAYgBzAHQAcgAoACQAXwAsADcALAA1ACkA
Error: File not found - ZgBpAGwAZQBuAGEAbQBlADsAJABfAD0AcwB1AGIAcwB0AHIAKAAkAF8ALAA0ACwAMwApAC4AJwAgACcALgBzAHUAYgBzAHQAcgAoACQAXwAsADcALAA1ACkA

And All the ImageDescription are replaced by $

So i do something wrong but no idea what, can someone help me pls

Btw syy for poor english  :-[

StarGeek

I suspect that you are using PowerShell.  Doing some quick tests I see similar output, especially when not quoting the part of the command with the less than sign <. Commands with dollar signs can also cause problems in PowerShell.

Try using CMD and make sure you put quotes around the parts with the less than sign.

D:\__OurProgs\exiftool\exiftool "-ImageDescription<${filename;s/^.{11}(.*)\..*$/$1/}" -overwrite_original -r -m -F "D:\____Bewerken\Foto"

TIL PowerShell doesn't necessarily need quotes around a less/greater than sign in a tag copy operation.
* 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).

Phil Harvey

Can you use single quotes in PowerShell to prevent expansion of "$" variables?

- 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

Quote from: Phil Harvey on January 10, 2024, 12:33:53 PMCan you use single quotes in PowerShell to prevent expansion of "$" variables?

Yes, but there are problems depending upon the command.  For example, the second command in this post shows that single quotes are not enough. Something in the -if condition requires escaping.

Here's an example of not needing quotes around a redirection, but adding the braces that would spit out some garbage


I no longer have the patience to figure out PS's idiosyncrasies beyond running a command to verify an error. It's too much of a pain to do so.
* 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).

Phil Harvey

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

groofie

#5
Tx guy's and idd the problem is powershell, stupid of me because in the manual only command prompt is marked.

I used the different proposials and marked the results. What i understand is that with commandprompt i have to use " and with powershell '.

D:\__OurProgs\exiftool\exiftool "-ImageDescription<${filename;$_=substr($_,11);s/\.[^.]*$//}" -overwrite_original -r -m -F "D:\____Bewerken\Foto"

Powershell
Warning: No writable tags set from D:/____Bewerken/Foto/

  64 directories scanned
    0 image files updated
1009 image files unchanged

Command prompt
  64 directories scanned
1009 image files updated

D:\__OurProgs\exiftool\exiftool '-ImageDescription<${filename;$_=substr($_,11);s/\.[^.]*$//}' -overwrite_original -r -m -F "D:\____Bewerken\Foto"

Powershell

  64 directories scanned
1009 image files updated

Command prompt
Het systeem kan het opgegeven bestand niet vinden.
Tx to your answers i don't have change al the descriptions manual. And there are much famililyfoto's. The 1009 listed are only a partial of them, and are a copy that i use to test and play  :)

StarGeek

Quote from: groofie on January 11, 2024, 08:52:43 AMTx guy's and idd the problem is powershell, stupid of me because in the manual only command prompt is marked.

Not stupid at all.  Windows defaults to PowerShell unless you specifically try to run CMD.
* 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).