ExifTool Forum

ExifTool => Newbies => Topic started by: matt07 on November 10, 2021, 08:20:17 AM

Title: Help needed for automatic processing
Post by: matt07 on November 10, 2021, 08:20:17 AM
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
Title: Re: Help needed for automatic processing
Post by: StarGeek on November 10, 2021, 10:02:18 AM
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 (https://i.imgur.com/safVJoA.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) (https://web.archive.org/web/20180120021145/http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx?mfr=true) for some details.  Or search on Windows batch parameters (https://www.google.com/search?q=Windows+batch+parameters).  The Archive.org page was the simplest I could find in a hurry.
Title: Re: Help needed for automatic processing
Post by: ryerman on November 10, 2021, 11:13:17 AM
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.
Title: Re: Help needed for automatic processing
Post by: ryerman on November 11, 2021, 07:59:13 AM
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
Title: Re: Help needed for automatic processing
Post by: Phil Harvey on November 11, 2021, 09:44:46 AM
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 (https://exiftool.org/faq.html#Q17) explains this technique.

- Phil
Title: Re: Help needed for automatic processing
Post by: CricketX on November 11, 2021, 05:45:02 PM
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!
Title: Re: Help needed for automatic processing
Post by: matt07 on November 16, 2021, 05:10:30 AM
That's great! Your suggestions work really well. Thanks for the great ideas!   :)