ExifTool Forum

ExifTool => Newbies => Topic started by: Terminus on September 21, 2013, 07:54:14 PM

Title: Parallel directory structure for output
Post by: Terminus on September 21, 2013, 07:54:14 PM
I just started using exiftool today, so far I'm really impressed but I'm still figuring things out...

I want to take a bunch of photos with metadata from Microsoft Windows Live Photo Gallery and import into iPhoto.
I've got the metadata converting properly, but I'd like the output to have the same recursive directory structure as the original.

exiftool "-iptc:Caption-Abstract<exif:XPComment" "-iptc:Keywords<exif:XPKeywords" -o /outputdir/ -r /sourcedir/

This works but the output directory is flat, subdirectories aren't created inside it. 

Is there a way to make the directory structure of the output match the original?

Thanks!
Title: Re: Parallel directory structure for output
Post by: Phil Harvey on September 22, 2013, 07:20:27 AM
Here is one way to do what you want:

cd /sourcedir
exiftool "-iptc:Caption-Abstract<exif:XPComment" "-iptc:Keywords<exif:XPKeywords" -o /outputdir/%d -r .


Alternatively, you could use one of exiftool's slightly more advanced features and do it like this:

exiftool "-iptc:Caption-Abstract<exif:XPComment" "-iptc:Keywords<exif:XPKeywords" -o /outputdir/%:2d -r /sourcedir

From the application documentation (https://exiftool.org/exiftool_pod.html):

            For %d, the field width/position specifiers may be applied to the
            directory levels instead of substring position by using a colon
            instead of a decimal point in the format specifier.  For example:

                Source Dir     Format   Result       Notes
                ------------   ------   ----------   ------------------
                pics/2012/02   %2:d     pics/2012/   take top 2 levels
                pics/2012/02   %-:1d    pics/2012/   up one directory level
                pics/2012/02   %:1d     2012/02/     ignore top level
                pics/2012/02   %1:1d    2012/        take 1 level after top
                /Users/phil    %:2d     phil/        ignore top 2 levels

            (Note that the root directory counts as one level when an absolute
            path is used as in the last example above.)

- Phil