Applescript change directory terminal

Joined
Feb 6, 2016
Messages
2
Reaction score
0
Points
1
I have the following terminal command that I want to automate using applescript. After cd to the folder that holds the .pdf files. This code looks at the first letter of the file name and based on that sorts the files into the alphabet folder corresponding to the first letter of the file.

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

Not sure how to get this to work. It will not run in applescript. Any insight is appreciated.

Thanks
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Is there any particular reason that you're doing this through an AppleScript and not through a shell script? If this is all you're doing, just stick that command in a shell script and voila.
 
OP
G
Joined
Feb 6, 2016
Messages
2
Reaction score
0
Points
1
Is there any particular reason that you're doing this through an AppleScript and not through a shell script? If this is all you're doing, just stick that command in a shell script and voila.

Not sure how to do shell scripts. Is it possible to show me so I can get started and try to learn.

Thanks
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
A shell script is nothing more than (at least in their basic form) a list of commands to execute. Here's (outdated link removed) a starter reference for you.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top