ExifTool Forum

ExifTool => Newbies => Topic started by: vulpess on January 19, 2022, 09:38:29 AM

Title: Moving files based on makernotes tag
Post by: vulpess on January 19, 2022, 09:38:29 AM
Hi,

I am a completely newbie when it comes to programming and coding and need some help for a specific task.

The scenario is the following:
I have a folder with a lot of jpg-files. Each file has either "A" or "B" in a specific makernotes tag.
I want to move the files with "A" into a subfolder named "A" and the files with "B" into a subfolder named "B".

Is there a solution with ExifTool?

Thanks in advance!

Cheers,
Lukas
Title: Re: Moving files based on makernotes tag
Post by: StarGeek on January 19, 2022, 10:22:30 AM
Probably, but it may depend.  This command will move files into a directory with the exact name in the tag.
exiftool "-Directory</path/to/target/${TAG;}" /path/to/files/

Replace /path/to/target/ and /path/to/files/ with the actual paths to the target and source directories.

Replace TAG with the actual name of the tag.  Make sure it's the tag name and not the description (see FAQ #2 (https://exiftool.org/faq.html#Q2) and FAQ #3 (https://exiftool.org/faq.html#Q3)).

Since I don't know the exact tag, I've added the braces and the semicolon.  This will make sure that characters that would be illegal in a file name, such as colons/slashes on Windows, will be removed.

Also, files that don't have that tag will not be moved.  You can set a default by placing another Directory assignment first.
exiftool -Directory=/path/to/default/ "-Directory</path/to/target/${TAG;}" /path/to/files/

If you're running under Mac/Linux/Powershell, change the double quotes to single quotes.

See Writing "FileName" and "Directory" tags (https://exiftool.org/filename.html) for more details.
Title: Re: Moving files based on makernotes tag
Post by: vulpess on January 19, 2022, 11:13:47 AM
Wow, that worked! Thanks so much, I would never have come up with anything similar  :o