Anybody know why this doesn't work?

I am trying to rename a file. I started with the following code.


tell application "Finder"
	set dtFilePath to (path to the desktop folder)
	set originalFile to ((dtFilePath & "Picture 1.png") as string)	set newFile to ((dtFilePath & "MakeMeASandwich!.png") as string)	
	set name of file originalFile to newFile
end tell


Looking thru the forum I have not found any reason that this shouldn’t work. I know that the “Picture 1” file exists, it is created earlier in the script (and I have verified this as a stand alone) but the finder give an error that it can’t complete the operation.

Thanks
Dee

Hi,

The new name shouldn’t incude the full path. Try this:

tell application "Finder"
	set dtFilePath to (path to the desktop folder)
	set originalFile to ((dtFilePath & "Picture 1.png") as string)
	set newFile to "MakeMeASandwich!.png"
	set name of file originalFile to newFile
end tell

Bestr wishes

John M

Thanks I found that out thru experimenting

But thanks anyway

Dee