Author Topic: Feature request: Handling -o[+|!] option in the same way than -w[+|!] did it  (Read 328 times)

plpub

  • Newbie
  • *
  • Posts: 6
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
Pierre

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Hi Pierre,

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

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

plpub

  • Newbie
  • *
  • Posts: 6
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
Pierre

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

plpub

  • Newbie
  • *
  • Posts: 6
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
Pierre

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

plpub

  • Newbie
  • *
  • Posts: 6
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
Pierre

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

plpub

  • Newbie
  • *
  • Posts: 6
Hi Phil,

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

To create sidecar:
Code: [Select]
-o %d%f%c.xmp -xmp
To resync image file from sidecar:
Code: [Select]
-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)
Code: [Select]
-filename=%d/trash/%f%-c.%e -ext xmp %d
Pierre

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

plpub

  • Newbie
  • *
  • Posts: 6
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 :-(
« Last Edit: February 22, 2019, 12:40:23 PM by plpub »
Pierre

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).