Applescript change folder and terminal commands

applescript

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

Best Answer

General when using the do shell script command, you will need to use the quoted form property of text objects. In other words, do something like this.

set command to "ls"
set result to do shell script quoted form of command
display dialog result