Simple Duplicate and Rename Script

I am trying to do something that I’m sure is incredibly simple, but I can’t figure it out. The goal is to open a file-picker, choose a file, then have Applescript duplicate that file to a new folder and rename the new file.

What I have so far is:

set TheFile to (choose file with prompt "Select Photo...")


set ThePath to POSIX file ("/Users/New/Folder/Path/Photos/")
set NewName to "New Photo Name.jpg"

set OldName to name of TheFile as string

tell application "Finder"
	duplicate TheFile to ThePath with replacing
	set name of alias ((ThePath & OldName) as text) to NewName
end tell

But I’m getting an error saying can’t make alias into string… I’m sure I am confused by variable types.

Model: MacBook Pro w/ Retina Display
AppleScript: 2.4
Browser: Safari 537.36
Operating System: Mac OS X (10.8)


put the line set OldName . into the Finder tell block. AppleScript has no idea to get the name from an alias specifier but the Finder has. You can also omit the as string coercion. The name property is always a string

Yes! Thank you! Working great. I knew it would be a super simple fix.