Adding metadata to image file and moving it

Hi, I have a folder action set up that moves incoming files into a new folder. This action is set up on multiple folders bringing all the files into one. Im trying to mark the files with a metadata tag so I know which folder they came from. This is where Im at putting in a exiftool code I found here on the forum, but Im not sure how to input the execute shell script command and ideally I'd like to add it as a keyword. The action also logs the filename and path in a text document in the lower part of the action, but that already works :slight_smile:

Any help would be greatly appreciated!



Can you show me how you would specify the correct syntax for the exiftool command if you were using it on the command line? If you can show the command line version's syntax, I'm sure I can help you implement the correct KM action.

I found some examples of exiftool online, and it usually requires that the filename be passed as a parameter to the command, but you are passing the name of the file to the command's input stream instead. So I'm guessing you need to change the input to Nothing and add the string $KMVAR_TriggerValue to the command line instead.

There are probably people on this forum that would be able to give you a 100% perfect answer, but I'm not one of those wizards so my answer is only probably correct.

Hi, thanks for looking at this! I managed to come a bit further after I wrote this post and did like you say over, put the input to nothing and did this as the shell script:

/usr/local/bin/exiftool -Description='My New Description' "$KMVAR_TriggerValue"

Unfortunately I don't know the correct command line syntax as Im working quite far from my comfort zone, but the macro as it stands gives me this error:


It seems to be to have something to do with the format of the TriggerValue maybe?

I just noticed something in your original post that might explain why this hasn't been working. What happens if you change this part in your original macro from this:


to this?


Hi gglick, thanks I tried it now, its then says no file specified, it seems that exiftool don't want the "input from".

I see. In that case, you might try saving %TriggerValue% to a variable and using that in the command you were just trying:


Although %TriggerValue% might look like it's already a variable, it's technically a token, which can't be read in shell scripts, and is most likely why you were seeing that last error message.

I think the space in "Google Drive" is creating problems also, so I will use your method and replace in the variable " " with "\ "

The space wasn't a problem after all, making a variable from the TriggerValue worked! However now since this is a active folder probably it creates 28 copies of the file, is this because of the exiftool argument?

-overwrite_original_in_place helped me with writing the metadata into the existing file. However exiftool creates a .jpg_exiftool_tmp file that triggers the same macro to start working on that file, creating an error for that file but doing what it supposed to with the jpg file, is there any way of avoiding this?

Hmm. You could try an Assert action at the beginning of the macro to check if the newly added file is that temp file or not: