Problem renaming a file

G’day

I’m trying to add a name extension to afile, but the script won’t work.

Any suggestions please as to what I’m doing wrong. It’s giving me a ‘Can’t set name’ error in both lines.


tell application "Finder"
	set oneFile to path to desktop
	set oneFile2 to oneFile & "Disney Cover Foil" as text
	set TheInfo to info for alias (oneFile2 as text)
	if (file creator of TheInfo is "InDn") and (name extension of TheInfo) is missing value then
		set name of oneFile2 to (name of TheInfo) & ".indd"
		set name of oneFile2 to (name of TheInfo as text) & ".indd"
	end if
	
end tell
TheInfo

Stupid me, I suddenly realized I need to put ‘file’ in front of ‘onefile2’

Regards

Santa

Hi Santa,

your seem to be the grandmaster of coercion :wink:

Why do you use info for, when you are in a Finder tell block anyway
here is your script coercion free :cool:


tell application "Finder"
	set oneFile2 to file "Disney Cover Foil" -- with no path specification the file is on desktop
	set {creator type:FC, name extension:EX, name:NM} to oneFile2
	if FC is "InDn" and (EX is "" or EX is missing value) then
		set name of oneFile2 to NM & ".indd"
	end if
end tell

Thanks Stefan. I’m still learning.

Regards

Santa