save selected file at new location with name from clipboard

I have a finder window open and a file is selected, the new filename is in the clipboard.

How do i copy the file with the new filename to a new (specified) folder location

I think that should be fairly easy, but i dont have the syntax “at hand”…

I appreciate your help…

meerestier

Hi

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!!

Bit more info needed!

cheers

No, the clipboard text comes from elsewhere.

What i have is this right now:

but it doesnt work…

Let me restate in plain words: “Move selected file to new location and rename it with clipboard contents”

Thx

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)

Something like this:

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

Hi,

try this

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

Hi

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)