Problem calling with "-filemodifydate<datetimeoriginal" on windows 11

Started by FreddyFremad, November 25, 2024, 09:33:17 AM

Previous topic - Next topic

FreddyFremad

Hi,

I am a happy user of this fantastic util - and (to the best of my knowledge - the only one able to handle new canon cr3 format.

I develop an app (in TypeScript) for my personal use to manage my photos.

The "DOS" command:
R:\cmd.exe /C ""R:\exiftool.exe" -overwrite_original "-filemodifydate<datetimeoriginal" -GPSLatitude=55.48987 -GPSLongitude=9.472278 -m "Q:/Thumb/TH-jpg/P/2020/F/08-Aug/08-03_23 Ferie/08-13 tor - Kolding - Hjem/20200813-13_11_03-IMG_8520_TH.JPG" 1>R:/rd_test_out.txt 2>R:/rd_test_err.txt && exit"

Says:
The filename, directory name, or volume label syntax is incorrect.
But:
R:\cmd.exe /C "R:\exiftool.exe -overwrite_original -GPSLatitude=55.48987 -GPSLongitude=9.472278  "Q:/Thumb/TH-jpg/P/2020/F/08-Aug/08-03_23 Ferie/08-13 tor - Kolding - Hjem/20200813-13_11_03-IMG_8520_TH.JPG""Works - but gives a exiftool error

Error: Error reading StripOffsets data in IFD3 - Q:/Thumb/TH-jpg/P/2020/F/08-Aug/08-03_23 Ferie/08-13 tor - Kolding - Hjem/20200813-13_11_03-IMG_8520_TH.JPG

I have done various other tests, at it clearly is the "-filemodifydate<datetimeoriginal" part that troubles cmd.exe.
I need to have the " as the < otherwise would be a redirection.

Any hints to how to direct the parameters to exiftool?


The other problem is "known" but a bit odd too, as the file in question is a small jpg produced by irfanwiev (by downscaling the original) and with exifinfo transfered by exiftool like this:

exiftool -TagsFromFile source destination
Where source is an .CR3 file (in this case) and destination is the newly created .jpg

Should I have more parameters?

:-) Freddy

Phil Harvey

Hi Freddy,

You definitely have some quoting problems.

First, the double "" near the start of your first command is a clear error.  Typo in the post maybe?

Second, you're executing cmd.exe to execute exiftool.exe.  The first cmd.exe command will strip the quotes and pass unquoted argments to cmd.  After that, I don't know how cmd runs the exiftool.exe command.  If it passes the command by stringing together the arguments it received then they will be missing the required quotes.  You'll have to double quote this somehow, but I'm not a cmd expert so I don't know the best way to do this.

IFD3 StripOffsets should not exist in a JPEG file, and ExifTool won't write this.  So this problem must have been caused some other way.  Upload some samples so we can test this if you think otherwise.

- 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: FreddyFremad on November 25, 2024, 09:33:17 AMSays:
The filename, directory name, or volume label syntax is incorrect.
...

Any hints to how to direct the parameters to exiftool?

This isn't an exiftool error. I did a google search on "how to pass a quoted argument to cmd.exe" and this StackOverflow answer seems relevant. When I remove all quotes except the ones around the tag copy and change the file redirects, I end up with an exiftool error instead of a system error.

C:\>cmd.exe /C exiftool.exe -overwrite_original "-filemodifydate<datetimeoriginal" -GPSLatitude=55.48987 -GPSLongitude=9.472278 -m "Q:/Thumb/TH-jpg/P/2020/F/08-Aug/08-03_23 Ferie/08-13 tor - Kolding - Hjem/20200813-13_11_03-IMG_8520_TH.JPG" 1>d:/rd_test_out.txt 2>d:/rd_test_err.txt && exit
Warning: Error opening file - Q:/Thumb/TH-jpg/P/2020/F/08-Aug/08-03_23 Ferie/08-13 tor - Kolding - Hjem/20200813-13_11_03-IMG_8520_TH.JPG
Error: File not found - Q:/Thumb/TH-jpg/P/2020/F/08-Aug/08-03_23 Ferie/08-13 tor - Kolding - Hjem/20200813-13_11_03-IMG_8520_TH.JPG
    0 image files updated
    1 files weren't updated due to errors

C:\>

Edit:
The Error reading StripOffsets data in IFD3 isn't something I'm knowledgeable about, except that IFD3 is very unusual in a JPEG.

None of the few CR3 sample files I have contain a IFD3 to begin with, so my testing it limited.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

Hmm.  From the stackoverflow post it seems that the double quotes were valid.  That syntax is unique.  The problem is then a missing double quote at the end?

- 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

Hmmm... So it does. I was going off the "Spaces in Program Path + parameters" part which had the parameters outside of quotes. And my test here shows that works when the quotes are only around tag copy. But quotes around the whole thing doesn't work.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

FreddyFremad

Quote from: Phil Harvey on November 25, 2024, 10:31:08 AMHi Freddy,

You definitely have some quoting problems.

First, the double "" near the start of your first command is a clear error.  Typo in the post maybe?

Second, you're executing cmd.exe to execute exiftool.exe.  The first cmd.exe command will strip the quotes and pass unquoted argments to cmd.  After that, I don't know how cmd runs the exiftool.exe command.  If it passes the command by stringing together the arguments it received then they will be missing the required quotes.  You'll have to double quote this somehow, but I'm not a cmd expert so I don't know the best way to do this.

IFD3 StripOffsets should not exist in a JPEG file, and ExifTool won't write this.  So this problem must have been caused some other way.  Upload some samples so we can test this if you think otherwise.

- Phil


I need cmd.exe in order to redicect stdout and stderr to my ramdisk (R:) - unless there is a way to specify these files directly to exiftool? I have looked for it, but have not found it.

FreddyFremad

Quote from: StarGeek on November 25, 2024, 10:31:47 AM
Quote from: FreddyFremad on November 25, 2024, 09:33:17 AMSays:
The filename, directory name, or volume label syntax is incorrect.
...

Any hints to how to direct the parameters to exiftool?

This isn't an exiftool error. I did a google search on "how to pass a quoted argument to cmd.exe" and this StackOverflow answer seems relevant. When I remove all quotes except the ones around the tag copy and change the file redirects, I end up with an exiftool error instead of a system error.

C:\>cmd.exe /C exiftool.exe -overwrite_original "-filemodifydate<datetimeoriginal" -GPSLatitude=55.48987 -GPSLongitude=9.472278 -m "Q:/Thumb/TH-jpg/P/2020/F/08-Aug/08-03_23 Ferie/08-13 tor - Kolding - Hjem/20200813-13_11_03-IMG_8520_TH.JPG" 1>d:/rd_test_out.txt 2>d:/rd_test_err.txt && exit
Warning: Error opening file - Q:/Thumb/TH-jpg/P/2020/F/08-Aug/08-03_23 Ferie/08-13 tor - Kolding - Hjem/20200813-13_11_03-IMG_8520_TH.JPG
Error: File not found - Q:/Thumb/TH-jpg/P/2020/F/08-Aug/08-03_23 Ferie/08-13 tor - Kolding - Hjem/20200813-13_11_03-IMG_8520_TH.JPG
    0 image files updated
    1 files weren't updated due to errors

C:\>

Edit:
The Error reading StripOffsets data in IFD3 isn't something I'm knowledgeable about, except that IFD3 is very unusual in a JPEG.

None of the few CR3 sample files I have contain a IFD3 to begin with, so my testing it limited.

Is it not what I am doing?
cmd /k ""c:\batch files\demo.cmd" "Parameter 1 with space" "Parameter2 with space""
except that I also have parameters without quotes?

R:\cmd.exe /C ""R:\exiftool.exe" -overwrite_original "-filemodifydate<datetimeoriginal" -GPSLatitude=55.48987 -GPSLongitude=9.472278 -m "Q:/Thumb/TH-jpg/P/2020/F/08-Aug/08-03_23 Ferie/08-13 tor - Kolding - Hjem/20200813-13_11_03-IMG_8520_TH.JPG" 1>R:/rd_test_out.txt 2>R:/rd_test_err.txt && exit"

exiftool.exe needs the quotes if it is not on my RAMdisk (R:) and the fil path needs quotes
the && exit says to exit exit exitcode is zero. Looks like a left-over from a test with cmd.exe /k :-)

StarGeek

Quote from: FreddyFremad on November 25, 2024, 11:18:37 AMIs it not what I am doing?
cmd /k ""c:\batch files\demo.cmd" "Parameter 1 with space" "Parameter2 with space""
except that I also have parameters without quotes?

I removed the outer quotes. The only quotes I have are around the parameter with the < sign and the ones with spaces.

As Phil pointed out, it seems that the outer quotes should work, but they obviously do not.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

Why exactly are you running through cmd.exe anyway?  I could see this if you wanted to view the console output, but you are piping these to text files.

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

FreddyFremad

Quote from: Phil Harvey on November 25, 2024, 12:45:22 PMWhy exactly are you running through cmd.exe anyway?  I could see this if you wanted to view the console output, but you are piping these to text files.

- Phil
I would like to run exiftool directly if i could set an output file as a parameter. Can I?
Otherwise I need to read the output - especially if they are error messages. I redirect to a RAM-drive so it is not a performance issue. I can send the output message to my user (it happens to be myself ;-)) in my program.

Phil Harvey

I see.

You can send stdout messages to a file using the -W+ option, but console warnings will still go to stderr.

Is there no way in TypeScript to redirect stdout and stderr before you run an external command?  You can do this in other languages fairly easily.

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

FreddyFremad

Quote from: Phil Harvey on November 25, 2024, 09:00:39 PMI see.

You can send stdout messages to a file using the -W+ option, but console warnings will still go to stderr.

Is there no way in TypeScript to redirect stdout and stderr before you run an external command?  You can do this in other languages fairly easily.

- Phil
Maybe that is a way :-)
From my front end I cannot access file system so I need to do it from node.js back end. Then there is always the problem with how many times unix type strings are parsed on its way from front end thru backend and thru node.js functions. " is a metasymbol so to get a " you need to make it \" but if that is parsed again it will be just the metasymbol ". If it is parsed again it should be \\" - and so the fun begins (next level is \\\\" because \ is also a metasymbol and to get one you need \\) :-)
I decided to make a small VBscript program to awoid this quote hell - and call that from backend with parameters not including metasymbols..

But definitely worth a try.

Phil Harvey

I have had to deal with the problem of multi-level quoting as well.  I feel for you.

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