0

I try to use automator for renaming multiple files

I got this far:

Automator screenshot

the first variable must be inside the Exiftool command line

in this case I selected 2 files, but that could be 1 or 100 files

how do I make this happen? is it possible to start from array key 1 instead of array key 0 for the filenames?

1
  • If you are asking how to shift the arguments, you can use shift, but note that the names and paths should be quoted or characters special to the shell (such as space) escaped. Commented Jun 10, 2022 at 18:49

1 Answer 1

1

The standard way to do this is to store $1 in a variable, then use shift to remove it from the argument list, and then use "$@" to get all of the remaining arguments (i.e. the original "$2" "$3" "$4" ...) Something like this:

RenameTo="$1"
shift
echo "New name: $RenameTo"
echo "files:" "$@"

I'm not sure exactly what you're trying to to with exiftool, so I won't try to give that full command.

Note that the double-quotes aren't required in zsh, but they make this portable to POSIX-compliant shells. Also, echo isn't a very good way to see what a command would do, because it looses the distinction between spaces within an argument (e.g. spaces in the new name, or within a filename) and spaces between arguments (e.g. between the filenamess in a list of them).

Sign up to request clarification or add additional context in comments.

1 Comment

Ahh I never new the shift command, that one works, thank you so much. Next step is using the exif tool, but this part works

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.