I’m looking to execute an Applescript from a Flash projector (on CDROM), that will move a file from the root level of the CD to the user’s desktop. It needs to work in Mac OS and OS X.
I’m totally new to Applescript. I’m wondering if anyone has seen something like this readymade, or could point me in the right direction.
I’m sure it must be possible. I’ve seen greg’s drag-n-drop “mover” script, which is similar to what i need to do, only his is more complex.
I just need the Finder to move a specific file (not user-selected) from the CD to the desktop when the script is executed. A “Save As” type dialog box would be swell, but not necessary.
Is it possible to execute a script that’s on a CD, or does it have to be installed on the user’s HD?
It’s possible to run a script from a CD. The following script might work once you provide the correct path to the file on the CD.
set ptd to (path to desktop) of startup disk
tell application "Finder"
duplicate file "path:to:file:on:cd" to ptd without replacing
end tell
I have no way to test this from a CD and I have no experience with Flash. As written, this script will not overwrite a file on the desktop if it has the same name as the file on the CD. You might need something more thorough in order to deal with the possibility that the file exists.
thanks rob. that seems like it will do exactly what i need it to.
one last question. how do i specify a file path on a CD? is it necessary to specify the file path if the file i’m moving is in the same directory as the script?
thanks rob. that seems like it will do exactly what i need it to.
one last question. how do i specify a file path on a CD? would it just be “cdtitle:downloads:filename.tif”, or do i have to start on the desktop level? is it necessary to specify the file path if the file i’m moving is in the same directory as the script?
set ptd to (path to desktop) of startup disk
set myPath to path to me as text -- path to script
try -- get the path to the folder which contains the script
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set targetFilePath to text items 1 thru -2 of myPath & "fileName" as text
set AppleScript's text item delimiters to oldDelims
on error
set AppleScript's text item delimiters to oldDelims
end try
tell application "Finder"
duplicate file targetFilePath to ptd without replacing
end tell
This is untested and there may be better ways to do it but this should be close to what you need. Sorry I don’t have more time to test this. :?