Have you used an applescript to get the name of the selected file or folder in the first place??
if so you won’t need to place it on the clipboard first!!
Only have a second so I can’t work out the whole script, but here is how you access the clipboard:
set newFileName to the clipboard
Is your intention to select a file in the finder, and then launch a script that will basically say take the current selection and copy it to a new location that is hard wired in the script (i.e. the user will not be prompted where to save the file to)?
Model: G5
Browser: Safari 419.3
Operating System: Mac OS X (10.4)
set the clipboard to "myName"
tell application "Finder"
set tCopy to duplicate item 1 of (get selection) to (path to desktop folder)
set name of tCopy to (get the clipboard)
end tell
tell application "Finder"
set thefile to item 1 of (get selection)
set newfile to duplicate thefile to folder "dataimages"
set name of newfile to (get the clipboard)
end tell
Looks like Adam beat me to it.
but here you go anyway.
tell application "Finder"
set t to selection as string
set a to t as alias
set b to duplicate item a to path to desktop folder
set name of b to the clipboard
end tell
this was tested with a finder window open with a folder selected and some random garble in the clipboard!!
I just tested this and it works usiing a shell to copy and rename in one step.
set PathToDesktop to path to the desktop as text
tell application "Finder"
activate
set thefile to selection as alias
set newfile to (PathToDesktop & "dataimages:" & (the clipboard as text))
set theShell to ("cp " & (POSIX path of thefile) & " " & (POSIX path of newfile))
do shell script theShell
end tell
Model: G5
Browser: Safari 419.3
Operating System: Mac OS X (10.4)