Advice using file names starting with ' ','-','#' in arg file in stay_open mode

Started by FrankB, November 01, 2024, 03:10:47 PM

Previous topic - Next topic

FrankB

First of all this could also have been posted in the ExifToolGui section. The trigger for posting this question is: https://github.com/FrankBijnen/ExifToolGui/issues/668
But I figured the outcome could potentially benefit all ExifTool users.

ExiftoolGui creates Arg files and they are processed in stay_open mode.
These Arg files contain a number of commands/tags (in the samples this is -filename), followed by one or more filenames, followed by -executenn

-filename
File1.jpg
-execute15

This works quite well, except for filenames that start with some special character. For now I have identified a space ' ', a hypen '-' and the number sign '#' as being problematic. But there could be more.

-filename
 File1.jpg
-File2.jpg
#File3.jpg
-execute15

- The leading spaces are removed by ExifTool when reading the arg file
- The hyphen denotes a tag, not a filename
- The number sign denotes comment

If have 2 workarounds.
Prefix the filename with '.\'. (This is my preferred method until now.)

EG:
-filename
.\ File1.jpg
.\-File2.jpg
.\#File3.jpg
-execute15

Use the complete filename, including the full path.

EG:
-filename
c:\foto\ File1.jpg
c:\foto\-File2.jpg
c:\foto\#File3.jpg
-execute15

Things that I looked at, but could not get to work:
- Quoting the filenames does not work in an Arg file. Single or Double.
- Prefix the filename with '#[CSTR]'. This works for ' ' and '#', but not for '-'. It is still a tag to ExifTool.

-filename
#[CSTR] File1.jpg
#[CSTR]-File2.jpg
#[CSTR]#File3.jpg
-execute15

- Use '--' to mark the end of the options, and force the rest as being filenames. The filenames will be recognized, but there is no way to start the execution with '-execute'. So not usable in stay_open mode.

-filename
--
 File1.jpg
-File2.jpg
#File3.jpg
-execute15

My question is: What would your preferred method be?

Thanks in advance,
Frank

For the record ExifTool 13.00 and Windows 10/11

Edit: Corrected sample 2nd workaround

StarGeek

And I'm just sitting here wondering what kind of madman starts their filenames with a space
:D
"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

FrankB

Quote from: StarGeek on November 01, 2024, 04:06:36 PMAnd I'm just sitting here wondering what kind of madman starts their filenames with a space
:D

I couldn't help thinking it was an effort to find a bug in GUI. But that doesn't prevent me trying to fix it.

greybeard

My Mac GUI version of ExifTool handles this just fine - but it always passes the complete path as a parameter

FrankB

Quote from: greybeard on November 01, 2024, 04:28:51 PMMy Mac GUI version of ExifTool handles this just fine - but it always passes the complete path as a parameter

On the command line, or also via an arg file? I ask, because on the command line you can use (single/double) quotes, and then there's no problem.

greybeard

Quote from: FrankB on November 01, 2024, 04:35:02 PM
Quote from: greybeard on November 01, 2024, 04:28:51 PMMy Mac GUI version of ExifTool handles this just fine - but it always passes the complete path as a parameter

On the command line, or also via an arg file? I ask, because on the command line you can use (single/double) quotes, and then there's no problem.


It uses a memory pipe to send the command to the STDIN of the exiftool process

FrankB

Quote from: greybeard on November 01, 2024, 04:42:31 PMIt uses a memory pipe to send the command to the STDIN of the exiftool process

Ah yes, that's another option. I assume you're quoting the filenames if they contain special characters? (On Mac single quotes)

greybeard

Quote from: FrankB on November 01, 2024, 05:12:16 PM
Quote from: greybeard on November 01, 2024, 04:42:31 PMIt uses a memory pipe to send the command to the STDIN of the exiftool process

Ah yes, that's another option. I assume you're quoting the filenames if they contain special characters? (On Mac single quotes)


I'm not sure thats needed - what sort of special character did you have in mind?


greybeard

Quote from: FrankB on November 02, 2024, 02:18:49 AMAs in the title, starting with space.



None of the examples in the title cause problems or require special handling

FrankB

On a Mac sure, but I'm on Windows and I use Arg files.

I will stay with '.\ File.jpg' for now.

greybeard

Quote from: FrankB on November 02, 2024, 03:38:49 AMOn a Mac sure, but I'm on Windows and I use Arg files.

I will stay with '.\ File.jpg' for now.

Fair enough - that wouldn't work for me as I want to be able to handle files from different folders concurrently - so sticking with the full path (or actually the URL data type under MacOS) makes most sense.

Phil Harvey

Yes, preceeding the relative path/file name with "./" is probably the way to go.

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

FrankB