ExifTool Forum

ExifTool => Newbies => Topic started by: Tribo0n on November 25, 2019, 01:52:20 AM

Title: Search for a word in all ptc fields -> If found move to a folder
Post by: Tribo0n on November 25, 2019, 01:52:20 AM
Hello,
i tried to move images with windows in batch with this code. But it dont works.
@echo off
FOR /F %%i IN ('findstr /s "Tesword" I:\Test') DO move /y %%i I:\Test\Searchresult
pause

Is there a way to search with EXIF Tool in a folder and his subfolders for a keyword in all IPTC fields and then move it to folder/subfolder/searchresult?
Title: Re: Search for a word in all ptc fields -> If found move to a folder
Post by: StarGeek on November 25, 2019, 03:07:34 AM
Hmmm...  I don't think so, not without naming the fields you want to check.  The command would get long and messy if you tried to do all of them on the command line.  Two ways around that would be to either put it all in an arg file or make a shortcut that contains all the tags.

But there are a lot of IPTC tags you are probably not using.  As an example, I have a shortcut that contains about 50 of the most common tags I've encountered so I can check for things like you're trying to do.  Additionally, if you're searching for a word, you wouldn't need to search any time stamp tags, numerical tags, Audio tags, or ICC_Profile tags.
Title: Re: Search for a word in all ptc fields -> If found move to a folder
Post by: Tribo0n on November 25, 2019, 03:48:21 PM
I have 2.000.000 Images and i would like to search for a specific photographer. So it might in 2-4 iptc fields, where i need to search.
Title: Re: Search for a word in all ptc fields -> If found move to a folder
Post by: Phil Harvey on November 25, 2019, 04:09:28 PM
You can do something like this:

exiftool -filepath -s3 -if "qq($by-line $credit ...) =~ /some name/i" -r DIR

- Phil
Title: Re: Search for a word in all ptc fields -> If found move to a folder
Post by: StarGeek on November 25, 2019, 04:15:45 PM
*types something out, sees Phil's response*

Very cool.

Since Tribo0n wants to move the files, something like
exiftool -if "qq($by-line $credit ...) =~ /some name/i" -directory="I:\Test\Searchresult" I:\Test
Title: Re: Search for a word in all ptc fields -> If found move to a folder
Post by: Tribo0n on November 26, 2019, 04:27:24 AM
Thanks, it works.
i put some commands to search in subfolders and to overwrite file if found same filename twice. Script now search in subfolders, but he cant overwrite the founded file if found twice. Whats wrong?
Quote@echo off
exiftool -if "qq($by-line $credit $artist $CopyrightNotice $Source $Contact $By-line $By-lineTitle $OriginalTransmissionReference) =~ /Testword/i" -overwrite_original -directory="I:\Test\Searchresult" I:\Test -r
pause
Title: Re: Search for a word in all ptc fields -> If found move to a folder
Post by: Phil Harvey on November 26, 2019, 07:02:21 AM
ExifTool will not overwrite existing files.  You can move these files by renaming them at the same time to add a copy number to the filename if there is a duplicate:

exiftool -if "qq($by-line $credit $artist $CopyrightNotice $Source $Contact $By-line $By-lineTitle $OriginalTransmissionReference) =~ /Testword/i" -overwrite_original -filename="I:\Test\Searchresult\%f%-c.%e" I:\Test -r


- Phil
Title: Re: Search for a word in all ptc fields -> If found move to a folder
Post by: Tribo0n on November 26, 2019, 10:05:26 PM
if i run the batch with your last code an error appears
No file specified
Title: Re: Search for a word in all ptc fields -> If found move to a folder
Post by: StarGeek on November 26, 2019, 11:25:07 PM
What is the exact command you used?
Title: Re: Search for a word in all ptc fields -> If found move to a folder
Post by: Tribo0n on November 27, 2019, 10:56:29 AM
The Code of Phil
exiftool -if "qq($by-line $credit $artist $CopyrightNotice $Source $Contact $By-line $By-lineTitle $OriginalTransmissionReference) =~ /Testword/i" -overwrite_original -filename="I:\Test\Searchresult\%f%-c.%e" I:\Test -r
Title: Re: Search for a word in all ptc fields -> If found move to a folder
Post by: Phil Harvey on November 27, 2019, 11:04:01 AM
The I:\Test is the file on the command line, so you shouldn't get a "No file specified" error.

- Phil
Title: Re: Search for a word in all ptc fields -> If found move to a folder
Post by: StarGeek on November 27, 2019, 12:10:34 PM
Does each quote have a match at the start of a option and end of an option?  Did you copy/paste into a word processor/goggle docs first?  If so, that might have changed the regular quotes into fancy quotes, which won't work.

Does your test "word" contain any of these characters \ /^${ }[ ]( ).*+?|  ?

Something isn't being typed correctly if it worked correctly the first time but not with Phil's change.

Some minor things, -overwrite_original isn't needed in this command as no embedded metadata is being changed, just the file location.  $By-line is listed twice, one of them can be removed, though the command will still function properly either way.