OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Find and Replace paragraph marks

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer
View previous topic :: View next topic  
Author Message
tlotzer1
Newbie
Newbie


Joined: 03 Feb 2007
Posts: 4

PostPosted: Sat Feb 03, 2007 7:52 am    Post subject: Find and Replace paragraph marks Reply with quote

I need to find and replace paragraph marks with the following: "^pRD " where ^p is the paragraph mark in some word proccesors.

In the Find and Replace box, if I turn on "regular expressions," I can use the $ to find the paragraph marks, but if I put this into the Replace field: "$RD " it replaces the paragraph mark with an actual dollar sign rather than a paragraph mark. I've read the Open Office help file for Regular Expressions but don't really understand all the details. The final syntax of the lines of text that I'm trying to alter are on the last lines of this message.

Here is what I'm trying to do. I need to fix a BAT file that was created by the steps in this help file below, that I found on the Internet, which deletes empty folders in a certain subfolder. I accomplished it in Microsoft Word, because the find/replace works for paragraph marks easily, but really want to do this in Open Office. Any help on the correct syntax, for the Replace field, would be appreciated.

Help file I found on the internet:

Delete Your Empty Folders
ARTICLE DATE:  02.01.03
By  Neil J. Rubenking
I'm looking for a program that can delete any folders that are empty or that contain only empty subfolders. Can you help?
M. V. Weir
You don't need a program; you can do this at the command prompt. Open a command prompt window and navigate to the root folder of the drive in question. Enter this command:

DIR /AD/B/S | SORT /R > EMPTIES.BAT
The file EMPTIES.BAT now contains a list of all folders on your hard drive in reverse order. Use Word or another editor to put the filenames in quotes and add the prefix RD (with a space after RD) to every line in the file. In Word, you can do this easily by using Find and Replace to search for ^p (which represents the paragraph mark) and replace it with "^pRD " (quote, p, R, D, space quote), then hand-correct the first and last lines of the file if necessary. Save the modified EMPTIES .BAT file and exit your editor. Then simply launch the batch file. It will attempt the RD (remove directory) command on each folder, but the command will fail for any folder that is not empty.
How does it work? For the DIR command, the switch /AD means select files whose attributes include the Directory attribute (in other words, folders). The /B switch means give a "bare" listing—just the filename—and /S means look in subfolders, too (which, incidentally, modifies /B, so it shows the full pathname). The output is piped (|) as input to the SORT command. Not surprisingly, the switch /R means sort in reverse. Finally, the output of SORT is redirected (>) into the file EMPTIES.BAT. Because we're sorting in reverse, every folder's subfolders precede it in the list. If they are empty, then by the time the parent folder is processed, it too will be empty. You'd be surprised at what you can do with simple commands!

dir/AD/B/S | SORT R/ EMPTIES.BAT

Here's what the line will look like in the BAT file:

RD "C:\Documents and Settings\Administrator\My Documents\Radio\BookmarksExportBuddy\WorkPC_IE\Yahoo!\Uncategorized"

RD "C:\Documents and Settings\Administrator\My Documents\Radio\BookmarksExportBuddy\WorkPC_IE\Yahoo!"
Back to top
View user's profile Send private message
BillP
Super User
Super User


Joined: 07 Jan 2006
Posts: 2703

PostPosted: Sat Feb 03, 2007 8:04 am    Post subject: Reply with quote

It's not easy in Writer.

Search the forum for all terms: replace paragraph marks
Back to top
View user's profile Send private message
tlotzer1
Newbie
Newbie


Joined: 03 Feb 2007
Posts: 4

PostPosted: Sat Feb 03, 2007 10:01 am    Post subject: Reply with quote

I found the answerusing BillP's suggestion.

The find field uses $ to find paragraph marks, but you must use \n in the replace field to place in paragraph marks.

Thanks to all.

The quote below is where I found the answer.

howard wrote:
J smith's problem can be solved by reading the internal help on regular expresions carefully!

For reasons only known to the programmers a paragraph is $ when searching, but \n when replacing. Use \n in your last step - I tried it and it worked.

So how do you replace with a newline (shift+space)? (Cutting and pasting into Find & Replace doesn't work here).

Perhaps Iannz macro does it.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group