Write contents of CDs to file

Can somebody please help me with a script that will allow me to do the following:

A window must open asking to proceed or quit.
On proceed, the script must write the volume name of the inserted CD to a text file, then ALL the files and folders on the disc (foldernames should start with something like “/F/” if possible.
Then start all over again!

The idea behind this is for me to create a simple catalogue of my CDs, which I will then pull into Excel.

You don’t say what’s on the CDs – Music or Data?

all this seems simple enough but can you confirm something for me? We can create a list of every folder on the CD and a list of every file on the CD but how would you no which file relates to which folder? I know that you’ve specified that you’d like to prefix a folder with “/F/” but you still wouldn’t know what files belong to a folder! does this matter?

Can you try running this script on your CD? It should return the contents of your CD and where it finds a folder it will specify the path of that folder and then the contents of that folder.

set thecd to choose folder --> choose your CD
tell application "Finder"
		set file_list to name of every file of thecd --> if there are any files on the top level of the CD make a list of them
	end try
	set top_level_list to ""
	repeat with this_top_level_item in file_list
		set top_level_list to top_level_list & (this_top_level_item as string) & return
	end repeat
		set folder_list to every folder of entire contents of thecd --> get a list of folders no matter how nested
	on error
		set folder_list to {}
	end try
	if folder_list is not {} then
		set complete_list to top_level_list
		repeat with this_folder in folder_list
			set content_list to name of every file of this_folder --> get a list of every file in a folder excluding sub folders
			set folder_contents to (this_folder as string) & return
			repeat with this_content_item in content_list
				set folder_contents to folder_contents & tab & (this_content_item as string) & return -->creates a list of files in a folder with a heading of the path to that folder
			end repeat
			set complete_list to complete_list & return & folder_contents
		end repeat
		set complete_list to top_level_list
	end if
	--display dialog complete_list
end tell