Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [OT] UNIX heads; can I do this?



I'm not really up on all of this shell scripting stuff, but it's pretty simple in Vanilla AppleScript:

set cr to ASCII character 13
set lf to ASCII character 10

set theFile to (choose file of type "TEXT") as text

try
	set fileRef to (open for access file theFile)
	set theText to read fileRef
	close access fileRef
on error errMsg number errNbr
	try
		close access fileRef
	end try
	error errMsg number errNbr
end try

set {od, AppleScript's text item delimiters} to ¬
	{AppleScript's text item delimiters, cr}
set theText to text items of theText
set AppleScript's text item delimiters to lf
set theText to theText as text
set AppleScript's text item delimiters to od

try
	set fileRef to open for access file theFile ¬
		with write permission
	set eof fileRef to 0
	write theText to fileRef starting at eof
	close access fileRef
on error errMsg number errNbr
	try
		close access fileRef
	end try
	error errMsg number errNbr
end try
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.