OK, this has got to be my like 100th script and I am so frustrated I can’t get this to work I’m about to go crazy:
Running 10.3.9:
I have a file named “blah” on my Desktop. If I run this script:
tell application "Finder"
choose file
set myFile to result
display dialog myFile as string
end tell
and select this file, as expected I get the result: “Polka:Users:pmac05:Desktop:blah”
With Polka being my startup disk, and pmac05 my username. Makes perfect sense, right?
Now, I want to rename the file! Not too complicated, right? So I add the line:
move myFile to "blah2"
And I get the insane error message: Finder got an error: Can’t get alias “Polka:Users:pmac05:Desktop:blah”
Now, correct me if I’m wrong, but if Applescript made the alias variable itself, and I didn’t move the file in between these 3 lines, how can it suddenly not find it? I ask this because I need to be able to rename a file that Photoshop created because Photoshop refuses to save it with the correct name (it’s Photoshop 7, with just enough applescript support to not work a little)
What’s really getting me about this is I’ve seen code exactly like this all over the web in other people’s scripts that supposedly works, but on my machine for some reason it just won’t!
All I want to be able to do is rename a file from applescript. If someone could just tell me a way to rename a file without resorting to a shell script or a POSIX path, I will love you forever. I can’t use a shell script because most of these files are on the network, and for some reason when applescript creates a posix path it neglects to account for the network volume’s place in the actual filesystem (instead of /Volumes/Server, it just goes to /Server, which is just flat out wrong).
How can a language billed as being so easy to use fail at such a simple request? Someone please tell me there’s a viable way…