• 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: Andrew Oliver <email@hidden>
  • Date: Tue, 14 Oct 2003 23:20:52 -0700

Open for access shouldn't fail if the file already exists - half the purpose
of the command is to open files so AppleScript can deal with its contents.

The typical way of doing what you want is something like:

set theFileRef to open for access file "path:to:file" with write permission
set EOF thefileRef to 0 -- reset the end of file to clear existing contents
write "something" to theFileRef
close access thefileRef

This appear to work every time for me whether the file originally exists or
not. Maybe you can post your code so others might see what's wrong.

Andrew
:)

On 10/14/03 10:15 PM, "Rua Haszard Morris" <email@hidden> wrote:

> Hi all,
>
> 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..?
>
> Cheers,
> Rua.
>
> Rua Haszard Morris
> Software Engineer & Research Assistant
> MARCS Auditory Laboratories
> http://www.uws.edu.au/marcs
> Ph +61 2 97726723 Fax +61 2 97726326
> _______________________________________________
> 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.
_______________________________________________
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: Re: Do shell script
  • Next by Date: Re: Illustrator Scripting Help Needed
  • Previous by thread: Re: open file for overwriting
  • Next by thread: Re: open file for overwriting
  • Index(es):
    • Date
    • Thread