Batch processing to sidecar files - Keeping directory structure

Started by dwlott, May 13, 2022, 03:49:37 PM

Previous topic - Next topic

dwlott

Hello, again guys,
I want ExifTool to create sidecar files while keeping the existing directory structure.  With the following commands that I am trying, the files in the source folder are extracted to sidecar files, but the files in the subdirectories produce an error.  For reference, I am looking at:https://exiftool.org/metafiles.html

This is what I am trying:
Create Sidecar files for a directory, keeping directory structure:
e:\exiftool\exiftool -TagsFromFile @ -all:all -srcfile "e:\myTargetFolder\%:2d%f.%e.xmp" -r "e:\mySourceFolder"

Create Sidecar files for Multiple files, keeping directory structure:
e:\exiftool\exiftool -TagsFromFile @ -all:all -srcfile "e:\myTargetFolder\%:2d%f.%e.xmp" "e:\mySourceFolder\Bracelets\File1.jpg" "e:\mySourceFolder\Bracelets\File2.jpg"

This is an example of the error message ExifTool is returning.  It looks like the slash is flipping.
Error: Error creating file: e:\myTargetFolder\Bracelets/File1.jpg.xmp - e:\myTargetFolder\Bracelets/File1.jpg.xmp

Windows 10
I'm having fun with ExifTool.  Thanks again for creating it.

StarGeek

Just to verify, you are creating XMP files in a completely different directory than the source jpgs?

Quote from: dwlott on May 13, 2022, 03:49:37 PMIt looks like the slash is flipping.

This is not a problem.  Exiftool is written in Perl and internally it treats all file paths as if they were regular slashes / instead of backslashes \.
"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

StarGeek

The problem in this case is that it will only write to existing directories.  New directories won't be created.

For the first run, you'll want to use the command in Example 11 so the directory structure will be created as well as the starting XMP sidecar files.  After that, then your command can be used to create new XMP in existing directories and update existing XMP files.
"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

dwlott

Thank you Stargeek, with your help I came up with this line that works great for creating sidecar files while keeping directory structure: 
e:\exiftool\exiftool -o "e:\myTargetFolder\%:2d%f.%e.xmp" "e:\mySourceFolder\Bracelets\File1.jpg" "e:\mySourceFolder\Bracelets\File2.jpg"

Is there a way to keep the directory structure the same way with an XML output? 
I tried a few things based on ExifTool -X a.jpg > a.xml, but could not get the directory structure to work with the -X option. 

StarGeek

"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

dwlott

Thank you again Stargeek.  With your last tip on looking at the -w option, I found that the following command lines work for me.

For XML sidecars keeping directory structure for a folder:
e:\exiftool\exiftool -r -X -w "e:\myTargetFolder\%:2d%f.%e.xml" "e:\mySourceFolder"

For XML sidecars keeping directory structure for multiple files:
e:\exiftool\exiftool -X -w "e:\myTargetFolder\%:2d%f.%e.xml" "e:\mySourceFolder\Bracelets\File1.jpg" "e:\mySourceFolder\Bracelets\File2.jpg"