• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: file rename occasionally fails last time through loop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: file rename occasionally fails last time through loop (From: Seth Tager <email@hidden>)

  • Prev by Date: Re: file rename occasionally fails last time through loop
  • Next by Date: Re: Timing execution?
  • Previous by thread: Re: file rename occasionally fails last time through loop
  • Next by thread: iCal Todo Question
  • Index(es):
    • Date
    • Thread