• 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: stripping resource forks from a file.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stripping resource forks from a file.


  • Subject: Re: stripping resource forks from a file.
  • From: Malcolm Fitzgerald <email@hidden>
  • Date: Thu, 8 Aug 2002 09:57:54 +1000

At 4:08 PM -0500 7/8/02, Simeon Johnston wrote:
I need to strip the resource forks out of a text file.
The problem is that we have a cvs server and are using maccvs to update to/from etc.
The files that are going to be used are just text files. But the program that create's them add's resource forks (just a custom icon really). This causes cvs to read it as a binary file.
Unless of course anyone here know's a way around this I'd like to strip the resource fork out of the file before it is commited to the cvs server. It would also be nice to reformat it as *nix text rather than mac (basically changing the line endings from carriage return to line feed).

Anyone have any idea how to do this with straight applescipt?
It could also be done with BBEdit or some such (save the file as a generic text file) but I'd rather not add additional app's into the process unless necessary (or if it makes it that much easier/safer).

Why muck around with resource forks? Just read the text in from the local file and write it out again (in a different location) as text


-- read the file
set fPath to (choose file{}) -- or substitute a file path
set fText to read fPath

-- convert to *nix
set Applescript's text item delimiters to (ascii character 13) -- return
set fText to every text item of fText
set Applescript's text item delimiters to (ascii character 10)
set fText to fText as string
set Applescript's text item delimiters to ""

-- write the file
set fPath to (choose file{}) -- or substitute a file path
try
set fRef to (open for access fPath with write permission)
on error number -49 -- file is already open
close access fPath
set fRef to (open for access fPath with write permission)
end try
set eof fRef to 0 -- ensure file is empty
write fText to fRef
close access fRef



--
Malcolm Fitzgerald
Database Manager
The Australian Society of Authors

phone: 02 9318 0877 fax: 02 9318 0530
http://www.asauthors.org mailto:email@hidden
_______________________________________________
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.

  • Follow-Ups:
    • Re: stripping resource forks from a file.
      • From: Simeon Johnston <email@hidden>
References: 
 >stripping resource forks from a file. (From: Simeon Johnston <email@hidden>)

  • Prev by Date: Re: selective string-replace
  • Next by Date: Not enough Memory errors
  • Previous by thread: stripping resource forks from a file.
  • Next by thread: Re: stripping resource forks from a file.
  • Index(es):
    • Date
    • Thread