1

forgive a newbie question.I have searched high and low but not found a similar situation.

I'm trying to create an automatic process where I can add keywords to jpg images.

I'm using Hazel to monitor a folder on my Mac and when it finds a file, it calls an Automator workflow script. Thus the script already receives one parameter (filename and path)

The shell script executes the following (using pass input: as arguments) (shell: /bin/bash)

for f in "$@"
do
    exiftool -keywords=myKeyWord "$1"
    exiftool -delete_original! "$1"
done

So far everything works. What I can't figure out is how to pass a second parameter from Automator that will allow me to input a keyword from a dialog box.

I have tried to a text field (Action: Ask for Text), and update the hardcoded value 'myKeyWord' with "$2", but it gives me an error stating "1 files weren't updated due to errors"

Any help would be greatly appreciated.

Thanks in advance,

Thomas

1 Answer 1

1

The loop is iterated for every parameter to the script. However, within the loop only the first parameter is being used: $1 instead of $f . So if you call the script with say 3 parameters it does the following:

exiftool -keywords=myKeyWord "$1"
exiftool -delete_original! "$1"
exiftool -keywords=myKeyWord "$1"
exiftool -delete_original! "$1"
exiftool -keywords=myKeyWord "$1"
exiftool -delete_original! "$1"

Perhaps you mean to do something like this (without a loop)? Just guessing :

exiftool -keywords="$2" "$1"
exiftool -delete_original! "$1"
Sign up to request clarification or add additional context in comments.

2 Comments

Yes, that is exactly what I want to do. I removed the loop statement but it still doesn't work. The statement is now only: do exiftool -keywords="$2" "$1" exiftool -delete_original! "$1" done Am I missing something?
@user3595091 Remove do and done, they should not be there . Also try to execute with set -x to see what is happening if it still does not work. I do not know what the command needs, you would need to check the man page..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.