Bulk CD Ingester. Loop a Script until a CD is inserted

Hi,

I’ve got a cool little script for bulk engesting CDs. I am using it to copy about 500 CDs to a FW drive on our network.

Anyway, right now it is running as a Folder Action on the /Volume directory so I pops up whenever a CD is inserted. However, I would rather launch it, set the destination folder, and have the script detect when a CD is inserted rather than the OS doing it with the Folder Actions. That way I could release it to others and they might find some good use for it.

Any ideas on how to setup that kind of loop?

Thanks,

  • T.
-- CD Archive Ingester 1.0
-- Copy a bunch of CDs or DVDs to another location (like an external FireWire Drive with minimal user interaction
-- This is a folder action that is attached to the "/Volumes" folder.
-- By T. Payton, onecreative.net



on adding folder items to this_folder after receiving added_items
	try
		-- variables
		set archiveCD to ""
		set cdName to ""
		set destinationFolder to alias "OC Live Archive:" -- the path to the folder where you want your music stored
		set appTitle to "CD Archive Ingester 1.0"
		say "Yum. I've got the disk" without waiting until completion
		
		display dialog "CD Insert Detected. We are groving." giving up after 2 with icon caution with title appTitle
		
		-- get name of inserted cd
		tell application "System Events"
			set archiveCD to 1st disk whose ejectable is true and local volume is true
			set cdName to name of archiveCD
			--	set cdPath to path of archiveCD
		end tell
		
		
		-- now copy that CD to the destinationFolder
		
		tell application "Finder"
			--	set theCDRom to "OC Archive 2005.21:" as alias
			set theCDRom to cdName as alias
			if folder cdName of destinationFolder exists then
				display dialog "This CD is already loaded up. Sweet. Grab another while I eject this one. Hang tight let me eject it." giving up after 3 with icon stop with title appTitle
			else
				display dialog "Copying. This will take a while." giving up after 3 with icon caution with title appTitle
				
				with timeout of 2400 seconds -- 40 minutes
					try
						duplicate theCDRom to destinationFolder
					on error
						say "I've got a problem. Bad Disk." without waiting until completion
						
						display dialog "Thee was a problem with this disc. Please put it aside to manually copy. I'll eject it now." giving up after 3 with icon stop with title appTitle
					end try
				end timeout
				
			end if
			
			eject cdName
			say "Feed me another CD please." without waiting until completion
			display dialog "Please feed me another CD." giving up after 10 with icon caution with title appTitle
		end tell
		
	end try
end adding folder items to

You could use the CDs & DVDs preference pane. There’s a choice in there to run an applescript whenever a cd is inserted.

you could also make an always on script (agent) using an on idle handler.

Oh sorry I wasn’t clear. I want to create a stand alone app that when run waits for a CD to run the duplicate script. The script is working great but takes some time to configure on a machine.

I was thinking to create a loop in the script that will just wait until a CD is inserted to exit the loop. But I’m to much of a newbie to know how to do this.

Here is my basic idea:


ask for destination folder
loop – main app loop

     loop
         exit loop if cd insert is detected
          delay 5 seconds
     end loop

 tell
 - copy cd to destination
 end tell
end loop

Thanks for your help

Hi regulus,

this works only in cases of a blank, music, picture or video CD / DVD,
but unfortunatly not with a data CD