ExifTool Forum

ExifTool => Newbies => Topic started by: Pereto on November 06, 2021, 04:38:08 PM

Title: copy selected files keeping structure
Post by: Pereto on November 06, 2021, 04:38:08 PM
Hello and thanks for everything.

I'm trying to recursively copy files that meet a condition, but I can't keep the original hierarchy in the destination directory.

I would appreciate if you would tell me where I am going wrong

I'm executing (Windows 10, powershell):
exiftool.exe -r -o DSTDIR -if '$category=~/Yecla/' SRCDIR
Title: Re: copy selected files keeping structure
Post by: StarGeek on November 06, 2021, 06:06:07 PM
Use the %d token as listed under the Advanced features of the -w (-TextOut) option (https://exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut).

I'm assuming that you want to remove a few of the top levels of the original directory path, so you would use %:#d, replacing the hashtag # with the number of top levels you want to remove and hardcode what you want in front of it.  For example, if your file path was C:\Level2\Level3\Level4\file.jpg and you wanted to remove the top two levels, your command would be something like
exiftool.exe -r -o DSTDIR\%:2d -if '$category=~/Yecla/' SRCDIR
and you would end up with
DSTDIR\Level3\Level4\file.jpg
Title: Re: copy selected files keeping structure
Post by: Pereto on November 06, 2021, 06:33:40 PM
Thank you very much, I'll try it
Title: Re: copy selected files keeping structure
Post by: Pereto on November 06, 2021, 06:38:56 PM
Great!. It's works.

thanks a lot