1

I have tried the following but cannot seem to get this to work:

do script "cd ~/desktop/test; for x in ls -1 | sed -e 's/^\(.\).*/\1/' | sort -u; do mv -i ${x}?* $x done"

I'm wanting to perform this command in applescript. I run this in applescript and I get an error regarding "" marks but am not sure how to correct it. I'm a complete newbie to applescript. willing to learn just a little lost.

Thanks

1 Answer 1

1

Note that in AppleScript, whenever you pass a shell script command with \, use \\ to represent it.

As:

do shell script "cd ~/Desktop/; for x in `ls -1 | sed -e 's/^\\(.\\).*/\\1/' | sort -u`; do echo ${x}?* $x; done"

Also, it uses for x in `command`, instead of for x in command. It's because `` treats everything inside it to be a command, and expects the result of this command, just as $():

do shell script "cd ~/Desktop/; for x in $(ls -1 | sed -e 's/^\\(.\\).*/\\1/' | sort -u); do echo ${x}?* $x; done"
Sign up to request clarification or add additional context in comments.

Comments

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.