• 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: Shell-sandwich a file in 2 variable strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shell-sandwich a file in 2 variable strings


  • Subject: Re: Shell-sandwich a file in 2 variable strings
  • From: Paul Strecker <email@hidden>
  • Date: Sat, 31 Jan 2004 21:46:48 +1100

At 3:29 AM -0700 31/1/04, Gnarlodious wrote:
How would I prepend a variable string to a file then append a variable
string to the same file?

The closest I can get is

do shell script "echo " & quoted form of startHTML & " " & htmlFilePOSIX & "
" & quoted form of endHTML & ">" & iPathPOSIX

But in this case the path of htmlFile is written instead of the file's text.
Maybe a variation of "cat" will work here, or piped commands.


I would suggest something like this.

set prepend_text to "whatever"

set append_text to "whatever"

set main_text to (read file "path:to:file.html")

set new_text to prepend_text & main_text & append_text

then write it all back to a file using any of a whole variety of write to file handlers.
_______________________________________________
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: 
 >Shell-sandwich a file in 2 variable strings (From: Gnarlodious <email@hidden>)

  • Prev by Date: Re: Shell-sandwich a file in 2 variable strings
  • Next by Date: Re: Shell-sandwich a file in 2 variable strings
  • Previous by thread: Re: Shell-sandwich a file in 2 variable strings
  • Next by thread: Re: Shell-sandwich a file in 2 variable strings
  • Index(es):
    • Date
    • Thread