• 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: How to add text to the beginning of a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to add text to the beginning of a file


  • Subject: Re: How to add text to the beginning of a file
  • From: Christopher Nebel <email@hidden>
  • Date: Wed, 22 May 2002 18:22:36 +0100

On Wednesday, May 22, 2002, at 04:18 PM, David Nelson wrote:

I'm sure someone will correct me if I am wrong, but I think the only way to add something to the beginning of a file is to read the whole file into a variable and then use the concatenation operator to prepend your data then write the data back to the file.

There are other slightly different techniques -- for instance, you could write the header to a different file, append the original, and then move the new file to replace the original -- but you'll still have to read the entire file and write it back out. There's no cheap way to do something like this [1].


--Chris Nebel
AppleScript Engineering

[1] Well, almost none. If the file format supports "dead" areas (e.g., comments in a Postscript file), you might be able to arrange for sufficient dead space to be in the original for you to replace with your new header. This technique works fairly well for "deleting" sections of a large file; it's less use for adding material, because you need the file's originator to cooperate.
_______________________________________________
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: How to add text to the beginning of a file (From: David Nelson <email@hidden>)

  • Prev by Date: Re: ignoring application completely
  • Next by Date: Calling specific files
  • Previous by thread: Re: How to add text to the beginning of a file
  • Next by thread: Changing machine name in OSX?
  • Index(es):
    • Date
    • Thread