Re: file rename occasionally fails last time through loop
Re: file rename occasionally fails last time through loop
- Subject: Re: file rename occasionally fails last time through loop
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 07 May 2003 10:28:20 -0700
On 5/7/03 10:11 AM, "Seth Tager" <email@hidden> wrote:
>
I assume I apply update to the specific file I'm
>
trying to rename. I modifed the script to this:
>
...
>
tell application "Finder"
>
set oldfilename to
>
"path:to:generated:Untitled.html"
>
update oldfilename
>
set the name of file oldfilename
>
to
>
"newname.html"
>
end if
>
end tell
>
...
>
>
It may have solved the rename file failure (didn't
>
happen the 10 or so times I tried), but now there's
>
another odd bug which is that the final rename command
>
sometimes (1 out of 9?) will create a file called
>
newfile.html, but that file will be empty, while the
>
orginal file, Untitled.html, will still exist and will
>
contain the expected contents. It's like it gets half
>
way through the rename and stops for some unreported
>
reason.
You're trying to update a string. You should be updating files. The Finder
is pretty good about doing coercions, but you're really pushing it.
tell application "Finder"
set oldfilename to "path:to:generated:Untitled.html"
set the name of file oldfilename to "newname.html"
update file "path:to:generated:newname.html"
end tell
(By using 'alias' you could avoid redoing the path, but it's usually better,
and advised, to use Finder terms in the Finder. Nevertheless, FWIW, here's
the other way:
set theAlias to alias "path:to:generated:Untitled.html"
tell application "Finder"
set the name of theAlias to "newname.html"
update theAlias
end tell
)
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.