0

I have an Automator application where I'd like to drag a folder onto it and have it create a duplicate (sibling) of that folder with the duplicate's files renamed. For example, starting with the following:

root
 +--svgs
     |--icons_a.svg
     +--icons_b.svg

When dragging the svgs directory onto the application, I would like to end up with the following:

root
 |--svgs
 |   |--icons_a.svg
 |   +--icons_b.svg
 +--renamed-svgs
     |--a.svg
     +--b.svg

I've tried the following: enter image description here

But it throws the following:

enter image description here

Not sure how to debug the error, but how can I get the first "Run Shell Script" action to return either the "renamed-svgs" folder or that folder's contents?

Or is there a better way to do this whole thing?

2 Answers 2

1

It is generally advisable to enclose a variable in double quotes.

Use the echo command to return the "renamed-svgs" folder

rm -rf "$@"/../renamed-svgs
cp -rf "$@"/ "$@"/../renamed-svgs
echo "$@"/../renamed-svgs/

Or use the find command to return files whose name start with icons_

rm -rf "$@"/../renamed-svgs
cp -rf "$@"/ "$@"/../renamed-svgs
find "$@/../renamed-svgs/" -type f -maxdepth 1 -iname 'icons_*' -print
0

This error is exactly what will happen for bash scripts if the application it is communicating with isn't a Running Application when it's interacted with. As for a better way to perform the task, no, automator is awesome.

  • I know, not a full answer, but I cannot comment and my statement is true.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .