Automate cd copying

I need to make an applescript that can make a copy of a cd and compress it with bzip2 -9. I’ve got a fair hum of how to do it. But how do I fetch the name of the CD as a variable?

Do I check for it in /Volumes/ ?

I’m sure there are better ways of doing this and this method may not work if you have other ejectables including external HDs, Zips, Jaz, etc., but you could try:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

This works, but it ain’t pretty and may poop things. I tried it and it didn’t harm anything I could see. The script creates a tar-archive of the mounted CD folder in /Volumes on the Desktop, which is subsequently bzip2-ed as archive.tar.bz2.



do script "tar -cf ~/Desktop/archive.tar '/Volumes/CD Name' | bzip2 ~/Desktop/archive.tar"


Hope this helps,

P.

So, putting it together, you can try this (untested):

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Ok tar wasn’t very good, since it doesn’t save the resource fork. Anyway ‘ditto -rsrc’ is better.

And when you unpack the .tar it will be a folder called Volumes and inside it you’ll find the CD.

do shell script "ditto -rsrc " & the_cd & " " & target_file & "  | hdiutil create -srcfolder " & target_file & "  " & cd_name & " "

I can’t get the hdiutil line to work… Everything else works fine btw. There can’t be any spaces in the cd_name (say My CD 2) any way of converting the spaces to _ ?

You can do “My CD” in the command line but I can’t put the " " in the applescript because then I get errors.

Ie I want to do

hdiutil create -srcfolder " & target_file & "   "" & cd_name & "" "

But I can’t since I’ll get compile errors.

What about this?

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

You get this

do shell script “ditto -rsrc ‘/Volumes/Brood War CD’ ‘/Users/isbiten/Desktop/Brood War CD’; hdiutil create -srcfolder ‘/Users/isbiten/Desktop/Brood War CD’ ‘Brood War CD’”
"hdiutil: create: image name parameter missing

Which means that (quoted form of cd_name) doesn’t get passed on to the shell.

Um, you see those single quote marks around the CD name? That means the quoted form is getting through. The problem is you are not using the hdiutil create command with the proper parameters (I didn’t look closely, I just told you how to use the cd name with spaces). How about this:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Works great! Sorry for being rude, I was tired of not getting it to work. :slight_smile: