Re: TextEdit, delete all blank lines
Re: TextEdit, delete all blank lines
- Subject: Re: TextEdit, delete all blank lines
- From: Deivy Petrescu <email@hidden>
- Date: Sat, 9 May 2009 15:21:37 -0400
On 09/05/2009, at 13:37 , John Masters wrote:
On 9 May 2009, at 09:52, Axel Luttgens wrote:
Le 9 mai 09 à 08:13, Satyam Satyanarayana a écrit :
Hi, Is there a way using apple script to delete all the blank
lines in the "rtf" file created by a TextEdit?
Hello Satyam,
TextEdit's AppleScript implementation is rather basic; so, unless I
missed the way to devise a clever whose clause, this seems to be a
prototype of the way to go with TextEdit:
tell application "TextEdit"
tell text of document of front window
repeat with P from (count of paragraphs) to 1 by -1
if characters of paragraph P is {linefeed} then delete paragraph P
end repeat
end tell
end tell
I sent a couple of replies to this thread but they seem to have gone
direct to Satyam, perhaps as a consequence of hijacking the original
thread instead of starting a new one. Anyhow, tested on the command
line the following works as a shell script:
"sed '/^ *\\$/d' filename1 > filename2"
so do shell script with the above should work. Has the advantage of
preserving the original file. I am only just starting Apple Script
but have done some shell scripting on Unix.
Regards, John
email@hidden
Well, in the name of purity.... :)
----->
set offendigChar to {9, 10, 32, 13}
tell application "TextEdit" to tell document 1 to repeat with jj from
(count paragraphs) to 1 by -1
set deleteit to true
tell paragraph jj
repeat with ll from 1 to count characters
if my getASCII(character ll) is not in offendigChar then
set deleteit to false
exit repeat
end if
end repeat
if deleteit then delete it
end tell
end repeat
on getASCII(x)
return ASCII number of x
end getASCII
--->
This removes blank lines that have spaces and tabs and ...
Deivy _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden