Terminal vs. Applescript

Joined
Sep 24, 2009
Messages
3
Reaction score
0
Points
1
I run the following script successfully in terminal in order to split an mp3 file into 3 smaller mp3 files...

split -b 8667k -a1 Monday.mp3 Levin-Hour_; ls Lev* | sed "s/.*/mv '&' '&.mp3'/g" | zsh

However, when I run a similar script within Applescript using the 'do shell script' command, the files split yet none of the 3 newly created files include the 'mp3' extension (they are in mp3 format however). Although I realize that I can simply rename the files within Applescript, the purist in me wants to know how to fix this. Here's what my Applescript command looks like...

do shell script "split -b 8667k -a1 Monday.mp3 Levin-Hour_; ls Lev* | sed " & "s/.*/mv '&' '&.mp3'/g" & "| zsh"

By the way, I know that I can easily split the file via a GUI editor. However, I am trying to run an automated script that downloads several files in a scheduled fashion. Therefore, I want to correct this via scripting if at all possible.

Any insight would be greatly appreciated.
 
Joined
Aug 3, 2009
Messages
1,562
Reaction score
39
Points
48
Location
The Netherlands
Someone will come along who will actually know this, but it's way out of my league.

Good luck;D
 
OP
T
Joined
Sep 24, 2009
Messages
3
Reaction score
0
Points
1
It's amazing how a good night's sleep can help one solve a problem. For those who ever want to do something similar using Applescript, I got it to work with these two lines...

set TheScript to "s/.*/mv '&' '&.mp3'/g"

do shell script "split -b 8667k -a1 Monday.mp3 Levin-Hour_; ls Lev* | sed " & quoted form of TheScript & "| zsh"

Bottom line - since the actual shell command included a statement with double quotes, I had to use Apple's quoted form statement to insure that the compiler read the double quotes as part of the script instead of just normal double quotes that would surround a string.
 

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