Help needed for automatic processing

Started by matt07, November 10, 2021, 08:20:17 AM

Previous topic - Next topic

matt07

Hello everyone,

I have two questions that I could use your help with:

1) I often assign keywords to my pictures. I do that with the command exiftool -sep "," -keywords+="Keyword 1, Keyword 2" and then drag the relevant folder or the individual images onto the cmd. It works very well. However, I find it annoying to have to re-enter this command every time I open the cmd. Do any of you know a way to open cmd and already load the command (without executing) so that I don't have to type it in again? That way I could tweak the keywords and then map the images...

2) Some keywords repeat themselves over and over again, e.g. a certain place. What should the batch file look like, onto which I drag the corresponding image using drag-and-drop and the keyword is applied to it? If I just save the command as *.bat as mentioned above, unfortunately nothing happens ...

I would be very happy to receive any help!

Best regards, Matt

StarGeek

Quote from: matt07 on November 10, 2021, 08:20:17 AMDo any of you know a way to open cmd and already load the command (without executing) so that I don't have to type it in again? That way I could tweak the keywords and then map the images...

I'm assuming Windows because you mention CMD.  But no, I've never heard of anything like that.

You might look into a text expander type program.  If you watch this gif, you can see where I just type et and it automatically gets replaced by the start of my basic exiftool command, exiftool -g1 -a -s

Quote2) Some keywords repeat themselves over and over again, e.g. a certain place. What should the batch file look like, onto which I drag the corresponding image using drag-and-drop and the keyword is applied to it? If I just save the command as *.bat as mentioned above, unfortunately nothing happens ...

You need to let Windows know about the files you're dragging and dropping.  In this case you probably want to use %*, e.g. exiftool -sep "," -keywords+="Keyword 1, Keyword 2" %*.  See this old page (via Archive.org) for some details.  Or search on Windows batch parameters.  The Archive.org page was the simplest I could find in a hurry.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

ryerman

#2
Quote from: matt07 on November 10, 2021, 08:20:17 AM
...Do any of you know a way to open cmd and already load the command (without executing) so that I don't have to type it in again? That way I could tweak the keywords and then map the images...
Here's a BAT file that allows you to enter keywords and then execute your command:

SET /P Keyword1="Enter Keyword 1: "
SET /P Keyword2="Enter Keyword 2: "
SET Command=exiftool -sep "," -keywords+="%Keyword1%, %Keyword2%"
START "" /b %Command% %1
PAUSE


Drag and drop a file or folder onto the BAT file.
Windows 10 Home 64 bit, Exiftool v12.61

ryerman

#3
Quote from: matt07 on November 10, 2021, 08:20:17 AM
...2) Some keywords repeat themselves over and over again, e.g. a certain place. What should the batch file look like, onto which I drag the corresponding image using drag-and-drop and the keyword is applied to it?
To avoid duplicating existing keywords, try this BAT file:

SET /P Keyword1="Enter Keyword 1: "
SET /P Keyword2="Enter Keyword 2: "
SET Command=exiftool -if "$Keywords!~/%Keyword1%/" -keywords+="%Keyword1%" -execute -if "$Keywords!~/%Keyword2%/" -keywords+="%Keyword2%" -common_args -sep "," %1
START "" /b %Command% %1
PAUSE
Windows 10 Home 64 bit, Exiftool v12.61

Phil Harvey

This would be a faster way to avoid duplicates:

SET /P Keyword1="Enter Keyword 1: "
SET /P Keyword2="Enter Keyword 2: "
SET Command=exiftool -keywords-="%Keyword1%" -keywords+="%Keyword1%" -keywords-="%Keyword2%" -keywords+="%Keyword2%"
START "" /b %Command% %1
PAUSE


FAQ 17 explains this technique.

- 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 ($).

CricketX

This is great to know!  I had no idea you could drag and drop folders onto a CMD window and it would act on each of the files in the folder.  Wow!

matt07

That's great! Your suggestions work really well. Thanks for the great ideas!   :)