On Mar 24, 2011, at 6:15 PM, John Haley wrote: I have been tinkering with this all afternoon and finally give up. I want to duplicate a file and change its name.
When I submitted my copyFile handler I could not remember with certainty the problem that I had encountered with using 'duplicate' that prompted writing that handler. It has been awhile. This afternoon I did a little experiment. What happens is that if you have an alias to a file and use that alias to change the name of the file, then the alias becomes corrupted.
Here's the experiment ...
set newName to "New_Folder_Name" tell application "Finder" set itemAlias to (folder "untitled folder 2" of (path to desktop)) as alias set name of itemAlias to newName end tell try (itemAlias as text) as alias on error errText number errNr "Error = " & errNr & ", " & errText log the result -- Error = -43, File /Users/lutherfuller/Desktop/untitled folder 2 wasn’t found. end try
There seem to be two bugs, here:
1. The line set name of itemAlias to newName should change the alias to comply with the new name. But it doesn't.
2. The Finder's 'duplicate' command should allow a properties list for the new file. It would be very useful to be able to write something like ... duplicate itemAlias to folderAlias with properties {name:newName} But you can't do that.
|