Search for a word in all ptc fields -> If found move to a folder

Started by Tribo0n, November 25, 2019, 01:52:20 AM

Previous topic - Next topic

Tribo0n

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?

StarGeek

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.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Tribo0n

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.

Phil Harvey

You can do something like this:

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

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

*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
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Tribo0n

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

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Tribo0n

if i run the batch with your last code an error appears
No file specified

StarGeek

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Tribo0n

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

Phil Harvey

The I:\Test is the file on the command line, so you shouldn't get a "No file specified" error.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

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.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).