Newbie: Copying a CD to a desktop folder?

Hi Guys,

I’m totally new to this, with no experience of scripting, but have tried to record a script which copies an inserted CD to a desktop folder but without any success.

Does anyone know of a script that will do this?
Is there a folder action that I could attach to a folder that would copy the CD’s contents if I dropped the CD onto the folder?

I’ve a lot of CD’s to archive to a HD and this sounds like the ideal way of doing it.

thanks,
Bartsimpsonhead

Let’s try this again.

property desktopFolderName : "Copied CDs"

on run
	set removeList to {(name of (info for (path to startup disk))), "Network"}
	set firstList to (list disks)
	set safeDiskList to {}
	
	repeat with i from 1 to (length of firstList)
		if {item i of firstList} is not in removeList then ¬
			set safeDiskList's end to item i of firstList
	end repeat
	
	if (length of safeDiskList) is 1 then
		open ({((item 1 of safeDiskList) as alias)})
	else if (length of safeDiskList) is 0 then
		display dialog "No discs or other volumes detected." buttons ¬
			"Cancel" default button 1
	else
		try
			choose from list (safeDiskList) with prompt ¬
				"Choose a disc:" default items {(item 1 of safeDiskList)} ¬
				without multiple selections allowed and empty selection allowed
			open ({(result as alias)})
		end try
	end if
end run

on open diskList
	try
		do shell script "mkdir -p " & quoted form of ¬
			(POSIX path of ((path to desktop as string) & desktopFolderName))
		repeat with thisDisk in diskList
			tell application "Finder" to duplicate disk thisDisk to ¬
				folder desktopFolderName of desktop
		end repeat
	on error errorMsg
		display dialog errorMsg buttons "Cancel" default button 1
	end try
	beep
end open

Model: Mac mini
AppleScript: 1.10
Browser: Safari 412
Operating System: Mac OS X (10.4)

guardian34,

Thanks for that, though it’s not working yet:

I try to run the script and an error message window pops up saying “File (name of the last CD I manually copied) not found” (which is different to the CD currently in the drive), while the script editor opens with the word “alias” highlighted in the line:

open ({((item 1 of safeDiskList) as alias)})

Any changes need to be made?

Cheers.

If it’s any help, the Event Log of the Script Editor says:

tell current application
	path to startup disk
		alias "Macintosh HD:"
	info for alias "Macintosh HD:"
		{name:"Macintosh HD", creation date:date "Saturday, January 25, 2003 10:00:35 pm", modification date:date "Thursday, May 26, 2005 8:32:07 pm", icon position:{0, 0}, size:missing value, folder:true, alias:false, name extension:missing value, extension hidden:false, visible:true, package folder:false, file type:"

That’s odd. I don’t have any problems when I try it here.

Edit: If you can manage to get the whole log in there, it might help.

  • Do you realize you can edit your posts instead of making new ones?

You can use the e-mail or PM links under my name to send the info, if that will work better.

that last message should have ended:

tell current application
path to startup disk
alias “Macintosh HD:”
info for alias “Macintosh HD:”
{name:“Macintosh HD”, creation date:date “Saturday, January 25, 2003 10:00:35 pm”, modification date:date “Thursday, May 26, 2005 8:32:07 pm”, icon position:{0, 0}, size:missing value, folder:true, alias:false, name extension:missing value, extension hidden:false, visible:true, package folder:false, file type:"

Again, following on from where it left off above, it should have read:

Ahhhhh! More missing txt…

Ahhhhh! More missing txt…

Sorry guys,

I’m trying to post the whole Event Log and it’s just missing off text the end of the messages.

I guess there must be some hidden characters in there somewhere which is knocking this stuff out.

As I’ve said, I’m kinda new to this…

E-mail didn’t work either!

Guardian34,

I think I’ll give up trying to send you the Error Log.
Basically it said that disk National45 #2 couldn’t be found, when disk National45 Disc1 was in the CD drive!

This may be an error in the way the disks were archived/named by the company supplying the disks (possible using PCs, or some sort of archiving software (as folders/files are saved over multiple disks)), but you’ll be pleased to know that I’ve tried your script with different disks burnt in-house, and on different machines, and your script works fine with all of these.

I think its a case of see what CDs work with the script and what I’ll have to copy manually.

Thanks,

Bartsimpsonhead