1

I have a .ICS document that I opened in Notepad.

When exporting the file, the calendar system watermarked every event description with a sentence. For a placeholder, I'll use:

This is a placeholder sentence with a web url http://example.com/null/.

I need to remove this sentence from a very long text file using only text editors that don't mess with indentation or formatting, because ICS's text format needs to be computer-readable.

Here's my problem. Lines are limited to 75 characters in ICS so the file ended up looking something like this:

DESCRIPTION: .................................. This is a placeholder senten
 ce with a web url http://example.com/null/.
DESCRIPTION: .......... This is a placeholder sentence with a web url http:/
 /example.com/null/.
DESCRIPTION: ......................................... This is a placeholder
  sentence with a web url http://example.com/null/.

The program broke off the sentence if it exceeded 75 characters and added a single-space indent on the next line. This, I assume, is for machine readability.

Problem is, that extra space voids any and all find-and-replace functions that I know how to use. It's random, it breaks up words, and I'm not sure what to do.

I need to use some sort of function or possibly a script that can ignore the linebreak AND indent. Any ideas?

  • You need to rebuild the full lines. A simple filter is a couple of line of C, but is pretty difficult in a script - I couldn't even get sed to do it, and it does most things. If it's only one file you may be able to find a binary editor which will do it (I was able to use frhed, but with difficulty). The Linux bbe command works (bbe -b '/\n/:2' -e 's/\n //g'), but I can't find a Windows port. – AFH Mar 21 '16 at 2:10
  • @AFH well, I better find a workaround for this. I'm in no position to be messing around with system commands. – breathlessblizzard Mar 21 '16 at 2:33
  • Just found a simple answer for single files: notepad++. In Extended match mode you can find and replace (by blank) all occurrences of \n . I always use this instead of notepad, but forgot about extended search mode. You can easily obtain it as a Portable App. – AFH Mar 21 '16 at 14:08
  • How can I get it to ignore the extra space? Is there a filter or something I can use? @AFH – breathlessblizzard Mar 21 '16 at 15:53
  • I just told you: search for new-line space. – AFH Mar 21 '16 at 15:57
0

Caution at the outset: Work on a copy of the file and be sure about the line breaks (some files have a carriage return and line feed):

You could search this site and read up on JREPL.BAT by dbenham or you could try out this hack on a copy of the file assuming:

a) Your .ICS file is a text file;

b) You only need to do this infrequently;

c) The DESCRIPTION never wraps onto the next line;

In Microsoft Word: highlight all the text (Ctrl+A) then open the find and replace dialogue using Ctrl+H on the keyboard:

Step_1 To find line breaks, type in the find box: "^l " (include the space after the lowercase L)

Step_2 In the replace box, type nothing.

Step_3 Click on replace all.

Step_4 Ctrl+click to the left of each placeholder line that you wish to remove, then press delete. (You could use the macro facility to do this automatically if this whole procedure works for you in general.)

OR you can use your usual tools to delete the placeholders.

Step_5 Save as a .txt file then rename it to .ICS

  • That's my problem. It doesn't split on the same word. – breathlessblizzard Mar 21 '16 at 15:52
  • I have edited my suggestion to remove the line breaks and space – TuesusMalnex Mar 21 '16 at 17:49
  • That doesn't seem to work. Word doesn't seem to accept ^l as a valid search argument. (Word 2013) – breathlessblizzard Mar 22 '16 at 0:53
  • Do a Find and Replace action like this in Word 2013: (1) Press these two keys together on the keyboard: Ctrl+H ; (2) Click on "More" ; (3) Click on "Special" ; (4) Click on "Manual Line Break" (or click on "Paragraph Mark" if that is what your file contains). You should now see ^l (or ^p) in the find and replace criteria. – TuesusMalnex Mar 30 '16 at 8:30

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.