Works in OS9 & from local disk OSX-NOT from CD in OSX

Hello,
I’m using this apple script code to download a file to the user’s desktop.
It works great in OS 9 and from my local disk in OSX , but not from a burned CD in OS X,
ANY SUGGESTIONS :


--set the name of the file to copy
property fileName : "test.doc"
--get the path to the containing folder
set myPath to (path to me as string)
set AppleScript's text item delimiters to ":"
set the parentFolder to ¬
((text items 1 thru -2 of myPath) & "") as string
set AppleScript's text item delimiters to ""
-- find the flash file
try
set targetFile to alias (the parentFolder & fileName)
on error
--ie if there's no file here by this name, it will quit.
return quit
end try
tell application "Finder"
move file targetFile to desktop
end tell 

I tried changing the delimiter to a slash and then compiling the script as an OS X application instead of a classic application, But no luck. Can anyone Help ???

Thanks.

My guess is that the problem is in the line:

move file targetFile to desktop

Surely if you’ve booted off CD, the desktop is a property of the CD and you can’t change the CD’s desktop (it’s a read-only volume).

Either that, or the problem is the use of ‘move’ instead of ‘copy’. When moving a file from one filesystem (the CD) to another (the user’s drive), ‘move’ will attempt to delete the original copy, which you can’t do because you’re on a read-only volume.

Try copying the file to desktop of the user’s hard drive instead.

Also, you shouldn’t use the line:

set AppleScript’s text item delimiters to “”

because you don’t know that AppleScript’s text item delimiters were null before you started. Instead, you should save and restore the previous delimiters, like:

set oldDelims to AppleScript’s text item delimiters
set AppleScript’s text item delimiters to “:”
– your code to work out the parent directory
set AppleScript’s text item delimiters to oldDelims

Alternatively, a safer all-round method is:

tell application “Finder”
set myPath to (container of (path to me) as string)
end tell

using the Finder’s ‘container’ property, you will always get the disk/folder name of the file in question.

thank you,
that worked out !!!