ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Atlantis on December 11, 2012, 01:42:04 AM

Title: Move CR2 files only if XMP exists
Post by: Atlantis on December 11, 2012, 01:42:04 AM
As the title says, I'm just after some advice as to how to move a bunch of CR2 files, but only move ones that have an associated XMP file, and to also move the XMP with it.

eg. I have a folder I:\Photos full of images edited with Lightroom. Not all photos were edited, so they won't have an XMP file.
I'd like to be able to move all of the I:\Photos\*.CR2 which have an XMP into a new folder I:\Final which also includes the XMP files.

I'm quite new to exiftool, and have done a few searches, but can't seem to find anything in the results that relate to the task I'm trying to perform.
The documentation for the tool is a little overloading at this point in time (being a newbie) so I was hoping for a pointer to the right direction.

Thanks!
Title: Re: Move CR2 files only if XMP exists
Post by: Phil Harvey on December 11, 2012, 07:14:40 AM
I don't recall anyone ever wanting to do this before.  It is a bit tricky because ExifTool really deals with just one file at a time.  But if we sneaky, I think we can accomplish what you want with 2 commands:

1) exiftool -tagsfromfile %d%f.xmp -aaa -directory=I:\Final -ext cr2 I:\Photos

This command will move any CR2 with a sidecar ".xmp" file from I:\Photos to I:\Final.  The -aaa is a bogus tag name that prevents ExifTool from copying any metadata to the CR2.  This command will produce a warning "No writable tags set from FILE" for each processed file, but it will move the CR2 files anyway.  CR2 images with no ".xmp" sidecar will give an error "File FILE does not exist for -tagsFromFile option" and they won't be copied.

Now to move the XMP files using the same technique:

2) exiftool -tagsfromfile I:\Final\%f.CR2 -aaa -directory=I:\Final -ext xmp I:\Photos

Here the only difference (other than switching "CR2" with "xmp") is that we must look in I:\Final for the CR2 image.

- Phil
Title: Re: Move CR2 files only if XMP exists
Post by: Atlantis on December 11, 2012, 05:49:07 PM
Hi Phil,

Thank you so much for the quick reply. I will give it a test later on today.
I also did a bit more research into standard DOS commands and found another way this can be achieved without the use of exiftool, and will post it here just in case anyone else searches for this method in the future:

Execute from the source folder. All edited files will be moved into the "Final" folder:

MKDIR Final
FOR %f IN (*.CR2) DO IF EXIST %~nf.XMP (MOVE %f Final & MOVE %~nf.XMP Final)

Cheers :)
Title: Re: Move CR2 files only if XMP exists
Post by: Phil Harvey on December 11, 2012, 08:15:49 PM
Your batch file solution is far better, and simpler, than the solution I gave.

- Phil