• 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: open file for overwriting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: open file for overwriting


  • Subject: Re: open file for overwriting
  • From: Steve Roy <email@hidden>
  • Date: Wed, 15 Oct 2003 09:43:54 -0400

Rua Haszard Morris <email@hidden> wrote:

> I'm trying to use open for access to open a file for writing to. If the
> file exists, I want it to be overwritten.
>
> I can't find an option for this, and an error occurs if I try to use open
> for access on a file that exists.
>
> How do I do this? Normally it's an option in the file open func..?

You use 'open for access with write permission' for this, but there's a caveat.

If you just pass a filepath as a string to 'open for access', then it will throw
an error if the file already exists.

open for access "HD:Users:steve:Desktop:foo"
--> Works the first time, but second time: "Duplicate file name" error
close access result

However, if you pass a file reference or an alias, then it will work as
advertised.

open for access file "HD:Users:steve:Desktop:foo"
close access result

or

open for access alias "HD:Users:steve:Desktop:foo"
close access result

Steve

--
Steve Roy <email@hidden>
Personal homepage: <http://homepage.mac.com/sroy>
Projects homepage: <http://www.roydesign.net>
_______________________________________________
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: 
 >open file for overwriting (From: "Rua Haszard Morris" <email@hidden>)

  • Prev by Date: Identifying a remote disk
  • Next by Date: Re: Identifying a remote disk
  • Previous by thread: Re: open file for overwriting
  • Next by thread: Re: open file for overwriting
  • Index(es):
    • Date
    • Thread