ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: mulcamd on January 22, 2011, 04:08:40 AM

Title: copy, move and rename xmp file together with the raw file
Post by: mulcamd on January 22, 2011, 04:08:40 AM
When extracting information from a RAW file, also the XMP is shown.
When moving the RAW file, the xmp file is left behind.

Since a xmp is not more than the metadata in a seperate file while the other metadata as EXIF and IPTC is in the file itselves, would it not be logical and possible that when moving or renaming a RAW file, also the xmp file is also moved or renamed.

One of my actual problems is that when renaming my RAW files with a sequence (xxx_0001, xxx_0002) the xmp is or not renamed when I select *.CR2 or the xmp files get a different number from my RAW file when I select *.* files.

Tips, suggestions ....
Title: Re: copy, move and rename xmp file together with the raw file
Post by: Phil Harvey on January 22, 2011, 07:12:56 AM
Quote from: mulcamd on January 22, 2011, 04:08:40 AM
When extracting information from a RAW file, also the XMP is shown.

The XMP is only shown by ExifTool if it is embedded in the RAW file.  ExifTool doesn't process sidecar XMP files unless you tell it to.

Quote
When moving the RAW file, the xmp file is left behind.

Yes.

Quote
Since a xmp is not more than the metadata in a seperate file while the other metadata as EXIF and IPTC is in the file itselves, would it not be logical and possible that when moving or renaming a RAW file, also the xmp file is also moved or renamed.

What about moving the XMP into the RAW file?:

exiftool -ext ARW -ext CR2 -ext NEF -ext PEF -tagsfromfile %d%f.xmp -xmp DIR

- Phil
Title: Re: copy, move and rename xmp file together with the raw file
Post by: mulcamd on January 23, 2011, 07:51:49 AM
Hi Phil,

First, thank you for Exiftool. This is one of the few programs I dare to touch my metadata with!

You are right about Exiftool not reading the xmp file. In my command I had *.*, so it read the CR2 and the XMP file.

To answer your question why not import the xmp into the RAW file:

Personally I think, as with database transactions (Create, Read, Update and Delete), the XMP, although it is outside the original RAW file, yet it should be treated as an internal part of it. This from the user perspective.
It stores essential information and other application add information to it. Their importance grows the more metadata is stored in them. Lightroom for example can store its settings / changes into the xmp file, as a backup.
Also xmp increases the portability between application. Lastly I see that almost no application changes the raw file it selves, but stores its information in the xmp.

Feature request:
Could an option be added that Exiftool handles the xmp files as it handles the raw file it belongs to SO that when the raw file is renamed, copied or moved, also the xmp file is renamed, copied or moved too. With the option on if should not handle the xmp apart from the raw file.
Title: Re: copy, move and rename xmp file together with the raw file
Post by: Phil Harvey on January 23, 2011, 10:03:50 AM
I agree with what you have said, and understand why you don't want to modify the RAW file, but there may be other alternatives:

If you give me a specific example of the command you use to rename your files, I should be able to show you how to modify it to also rename the XMP files.

- Phil
Title: Re: copy, move and rename xmp file together with the raw file
Post by: mulcamd on January 23, 2011, 02:10:25 PM
Hi Phil,

Thank you for the quick reply.

I use Geosetter to Geotag my photos. Under the hood it uses your Exiftool.
Geosetter does not export the filenumber information of my Canon 350D tool to XMP. This information is in the Makernotes of the raw files and not in the XMP file. I have no influence on how Geosetter makes the XMP file.

I name my images as
-r "-FileName<CreateDate" -d "D:/%Y/%m/%Y%m%d/DAH_%Y%m%d_$filenumber.%%e"

Actual I would like to have only the last 4 digits of the filenumber, see
https://exiftool.org/forum/index.php/topic,3069.0.html (https://exiftool.org/forum/index.php/topic,3069.0.html)

BTW I see the relationship between the RAW file and the XMP file as referential integrity in the database world between two tables. Does this makes a point?
Title: Re: copy, move and rename xmp file together with the raw file
Post by: Phil Harvey on January 23, 2011, 05:22:14 PM
Quote from: mulcamd on January 23, 2011, 02:10:25 PM
-r "-FileName<CreateDate" -d "D:/%Y/%m/%Y%m%d/DAH_%Y%m%d_$filenumber.%%e"

OK, assuming you start with same-named XMP and CR2 images, you could run this command before you rename the CR2 images:

exiftool -r -tagsfromfile %d%f.CR2 "-FileName<CreateDate" -d "D:/%Y/%m/%Y%m%d/DAH_%Y%m%d_$filenumber.%%e" -ext xmp DIR

This will move the XMP files.  Then follow this with the command to move the CR2's.

- Phil
Title: Re: copy, move and rename xmp file together with the raw file
Post by: Phil Harvey on January 23, 2011, 05:38:22 PM
Wait.  That won't work.  Your original command has a problem.

You need to do something like this instead (for both commands):

exiftool -r -tagsfromfile %d%f.CR2 "-FileName<${CreateDate}_$filenumber.$fileextension" -d "D:/%Y/%m/%Y%m%d/DAH_%Y%m%d" -ext xmp DIR

The FileExtension tag I used here is one of the ones defined in the sample config file, although for the XMP files you could just put "XMP" in the command instead.  And even though I've said this 1000 times:  Mac and Linux require single quotes around the argument containing the '$' symbol instead of double quotes as above.

- Phil

Title: Re: copy, move and rename xmp file together with the raw file
Post by: Phil Harvey on January 24, 2011, 07:39:59 AM
I had another thought.  I didn't need to use FileExtension because %e may be used instead.  Also, just to be complete I'll use your MyFileNumber tag from this thread (https://exiftool.org/forum/index.php/topic,3069.0.html):

exiftool -r -tagsfromfile %d%f.CR2 "-FileName<${CreateDate}_$myfilenumber.%e" -d "D:/%Y/%m/%Y%m%d/DAH_%Y%m%d" -ext xmp DIR

- Phil
Title: Re: copy, move and rename xmp file together with the raw file
Post by: mulcamd on January 25, 2011, 03:37:17 PM
Thanks Phil,

I will have a look at it tomorrow!
Title: Re: copy, move and rename xmp file together with the raw file
Post by: mulcamd on January 25, 2011, 05:21:18 PM
Hi Phil,

Thanks for all the help!
Still having problems.

My exiftool command in a windows batch file is:
dir "E:\Foto's\2010\09\2010_09_03 Slak op bloem\*.*" >output.txt
exiftool -v -v -r -tagsfromfile %%d%%f.CR2 "-FileName<${CreateDate}_$myfilenumber.%%e" -d "D:\%%Y\%%m\%%Y%%m%%d\DAH_%%Y%%m%%d" -ext xmp "E:\Foto's\2010\09\2010_09_03 Slak op bloem\*.CR2" >>output.txt


The output is:
De volumenaam van station E is Data
Het volumenummer is 1C3D-9219

Map van E:\Foto's\2010\09\2010_09_03 Slak op bloem

25-01-2011  22:18    <DIR>          .
25-01-2011  22:18    <DIR>          ..
25-01-2011  21:40               219 .ExifTool_config
10-09-2010  09:10         7.727.289 DAH_20100903_8345.CR2
10-09-2010  10:27             3.831 DAH_20100903_8345.xmp
10-09-2010  09:10         7.571.768 DAH_20100903_8347.CR2
10-09-2010  10:27             3.832 DAH_20100903_8347.xmp
22-01-2011  08:06         4.685.131 exiftool.exe
25-01-2011  22:27               854 output.txt
25-01-2011  22:27               179 test.cmd
               8 bestand(en)       19.993.103 bytes
               2 map(pen)  73.334.546.432 bytes beschikbaar
-------- E:/Foto's/2010/09/2010_09_03 Slak op bloem/DAH_20100903_8345.CR2 (wrong extension)
-------- E:/Foto's/2010/09/2010_09_03 Slak op bloem/DAH_20100903_8347.CR2 (wrong extension)

Btw on the terminal I also get the message: "No file with specified extension"

My .ExifTool_config lookes like:
%Image::ExifTool::UserDefined = (
   'Image::ExifTool::Composite' => {
       MyFileNumber => {
           Require => 'FileNumber',
           ValueConv => '$val =~/(\d\d\d\d)$/; $1',
       },
   },
);
1; # end


Is there something I overlooked?
Title: Re: copy, move and rename xmp file together with the raw file
Post by: Phil Harvey on January 25, 2011, 05:38:28 PM
Yes.  You specified "DIR/*.CR2" for the files to process.  Just specify the directory name instead.  

- Phil