Terminal vs. Applescript

I am running Mac OS X (10.5). 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 the Applescript editor 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. This may be more of an Applescript problem, but I thought I would at least throw it out there - thanks!!

I don't have much experience with applescript but it looks like you might need to escape the single quotes and possibly the pipe. Why are there ampersands in the middle of the command? Does it need to be split up that way?

Your points are valid. To be honest, the problem came about late last night and my brain was fried. I tried several combinations until it finally compiled as you see it. The program ran and compiled, but clearly something is not allowing it to complete with total success (e.g., no 'mp3' extensions). When I get home tonight, I'll play around some more with the ampersands, pipes, and single quotes until I can hopefully meet with success. Thanks for your suggestions !! :slight_smile:

---------- Post updated 09-25-09 at 10:06 AM ---------- Previous update was 09-24-09 at 03:14 PM ----------

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.