• 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: TextEdit, delete all blank lines
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TextEdit, delete all blank lines


  • Subject: Re: TextEdit, delete all blank lines
  • From: "Sutapalli Satyanarayana" <email@hidden>
  • Date: Sun, 10 May 2009 01:12:32 -0600

I found the cause why it is running on my Mac.

It is because, Initially I created "rtf" in TextEdit, then I opened it in MS  Word and applied some formatting.

So, when I am using the scripts provided by Axel or John, it is not working because MS Word might have changed the format of the file.


Thank you all who ever provided me the solution.

--Satyam.

>>> Philip Aker <email@hidden> 5/10/2009 9:00 AM >>>

On 2009-05-09, at 20:08:14, Sutapalli Satyanarayana wrote:


Still the sed script or the Script sent by Axel Luttgens is not working.


I'm using OS X 10.5.6. Both the 'sed' script and Axel's AppleScript work fine on my machine.

The AppleScript was insufferably slow.

I tried the following modification (foregoing it's ability to detect lines containing only spaces and tabs).

However, it is still insufferably slow:


script cozy_up

tell application "TextEdit" to tell document 1

repeat with i from (count paragraphs) to 1 by -1

if ((count of characters of paragraph i) is 1) then

delete paragraph i

end if

end repeat

end tell

end script

run script cozy_up



>>> John Masters <email@hidden> 5/9/2009 11:07 PM >>>



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.



Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@

Democracy: Two wolves and a sheep voting on lunch.


 _______________________________________________
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

References: 
 >RE: RE: Excel Save as text question (From: "Christian Sonntag <email@hidden>" <email@hidden>)
 >TextEdit, delete all blank lines (From: Satyam Satyanarayana <email@hidden>)
 >Re: TextEdit, delete all blank lines (From: Axel Luttgens <email@hidden>)
 >Re: TextEdit, delete all blank lines (From: John Masters <email@hidden>)
 >Re: TextEdit, delete all blank lines (From: "Sutapalli Satyanarayana" <email@hidden>)
 >Re: TextEdit, delete all blank lines (From: Philip Aker <email@hidden>)

  • Prev by Date: Re: TextEdit, delete all blank lines
  • Next by Date: Interacting with external shell scripts
  • Previous by thread: Re: TextEdit, delete all blank lines
  • Next by thread: Re: TextEdit, delete all blank lines
  • Index(es):
    • Date
    • Thread