ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: plpub on February 21, 2019, 11:48:54 AM

Title: Feature request: Handling -o[+|!] option in the same way than -w[+|!] did it
Post by: plpub on February 21, 2019, 11:48:54 AM
Hello  :)

I am using Exiftool as a command line of "Open with" option proposed by xnview MP in order to create an XMP sidecar file from a TIF file. I am using the following parameter for exiftool:
-o %d%f.xmp -xmp

This works well if the sidecar file does not already exists, but this command fails if the sidecar file exists (as explained in exiftool documentation).
I see that for the command line option -w, the option -w! can force to overwrite the output file so I would like to know if it could be possible to apply the same mechanism to the -o option.

Thanks in advance,
Pierre
Title: Re: Feature request: Handling -o[+|!] option in the same way than -w[+|!] did it
Post by: Phil Harvey on February 21, 2019, 11:59:21 AM
Hi Pierre,

I think that it would be dangerous to add the ability to overwrite image files with -o!.

- Phil
Title: Re: Feature request: Handling -o[+|!] option in the same way than -w[+|!] did it
Post by: plpub on February 21, 2019, 12:04:47 PM
Hi Phil,

The request is not to force to overwrite the image itself, but only the xmp sidecar file.
This action would happen only if the user explicitly add -o! instead of -o in its command line argument, so I don't think this would happen "unexpectedly"

Pierre
Title: Re: Feature request: Handling -o[+|!] option in the same way than -w[+|!] did it
Post by: Phil Harvey on February 21, 2019, 12:13:31 PM
Hi Pierre,

The -o option sets the name/directory of the output "image" file.  This option is more often used to make a copy of an image when editing (eg. -o OUTDIR/%f.%e) or when renaming the file.  Of course, nobody would add "!" by accident, but the problem occurs if someone thinks they want to overwrite old edited images but gets the command wrong so they overwrite some other images.  ExifTool is very complex and can be confusing, and preventing overwrite of image files is a safeguard against problems like this.

- Phil
Title: Re: Feature request: Handling -o[+|!] option in the same way than -w[+|!] did it
Post by: plpub on February 21, 2019, 12:49:11 PM
OK I understand Phil  :( ,

Another solution I see is to add in the FMT parameter, the %c to create a new version of the XMP file everytime I update the TIF metadata.
-o %d%f%c.xmp -xmp

This works well but I have then another problem: when I try to resynchronise a newly generated TIF with the last version of the XMP file, I cannot use the %c as input file command line option:
-tagsfromfile %d%f.xmp -all:all  -overwrite_original

If I try to use -tagsfromfile %d%f%c.xmp -all:all  -overwrite_original, this command line will fail trying to find the last version of the XMP file available.

Can you help me with my problem ?

Thanks in advance
Pierre
Title: Re: Feature request: Handling -o[+|!] option in the same way than -w[+|!] did it
Post by: Phil Harvey on February 21, 2019, 12:56:28 PM
Hi Pierre,

The thing to do is to remove the old XMP files before you generate the new ones.  If you want, you could use ExifTool to do it with a command something like this:

exiftool -filename=trash/%f%-c.%e -ext xmp DIR

This command will move all XMP files in DIR to a "trash" directory in the current folder.

- Phil
Title: Re: Feature request: Handling -o[+|!] option in the same way than -w[+|!] did it
Post by: plpub on February 21, 2019, 01:14:23 PM
Hi Phil,

Thanks very much for your help.

As I am using the "Open with" option of xnview, I do not have access to the name of the current directory. Is there an environment variable that I can use (I works with windows version of xnview)?

Pierre
Title: Re: Feature request: Handling -o[+|!] option in the same way than -w[+|!] did it
Post by: Phil Harvey on February 21, 2019, 01:16:07 PM
If you show me the exact command or arguments you are using for exiftool then I can show you how to do this in your "Open with" command.

- Phil
Title: Re: Feature request: Handling -o[+|!] option in the same way than -w[+|!] did it
Post by: plpub on February 22, 2019, 03:51:14 AM
Hi Phil,

I use Exiftool.exe with following parameters in the "Open with" command configuration:

To create sidecar:
-o %d%f%c.xmp -xmp

To resync image file from sidecar:
-tagsfromfile %d%f.xmp -all:all  -overwrite_original

I try the following command to move all intermediate sidecar files to trash but it does not work (last %d is not interpreted I presume)
-filename=%d/trash/%f%-c.%e -ext xmp %d
Title: Re: Feature request: Handling -o[+|!] option in the same way than -w[+|!] did it
Post by: Phil Harvey on February 22, 2019, 07:09:12 AM
Hi Pierre,

OK.  You only need to remove the XMP when creating a new sidecar.  So change this:

-o %d%f%c.xmp -xmp

to this

-filename=%d/trash/%f%-c.xmp -srcfile %d%f.xmp -execute -o %d%f%c.xmp -xmp

- Phil
Title: Re: Feature request: Handling -o[+|!] option in the same way than -w[+|!] did it
Post by: plpub on February 22, 2019, 12:15:23 PM
Hi Phil,

The command fails when there is no sidecar file.
And if I add a sidecar file, this command will move the existing sidecar file into trash but will not create a new sidecar file in the current directory. It seems that everything after the -execute is not interpreted.

I am trying right now to rename the Exiftool executable file to split the 2 commands (1 in the executable filename and 1 as argument) but it does not seems to work also :-(
Title: Re: Feature request: Handling -o[+|!] option in the same way than -w[+|!] did it
Post by: Phil Harvey on February 22, 2019, 12:31:00 PM
Hi Pierre,

Hmmm.  Darn.  I did forget a -common_args as a last option, but my idea will only work if the file name is added at the end of the command.  It seems that maybe it is added at the beginning (since you say the first command is executed, but the second isn't), and if so then my idea won't work.

- Phil