You must be logged in to post Login

Search Forums:


 






Find and Replace text then apply style

UserPost

6:09 pm
January 30, 2012


tabaholic

Member

posts 24

I have 200 .txt (opened in Word) that have lines and lines of text starting with a descripter and a colon.

I want to remove all text before and including the colon and space after the colon, then apply a style to "General".
Same thing on the next line, but with yet another style. and on and on and on. There are 45 instances I need to change otherwise I would just use Find and Replace.

For example,

Report Type: General
Report Year: 2011
Report Title: Scholarship Endowment
Event Description: Now is the time for all good men to come to the aid of the country.

I want to remove all text before and including the colon and space after the colon, then apply a style to "General".
Same thing on the next line, but with yet another style.

Can this be done?

11:34 am
January 31, 2012


Jongware

Member

posts 764

Look in your Scripts panel, under Application. There you can find FindChangeByList, a handy script that reads its input fromman accompanying plain text file.

As a footnote to the above script: you cannot remove text and apply a paragraph style at once. If there is no text in the "Change To" field but there is some formatting specified, ID just apllies the formatting — and, in general, that's a good thing too! But in your case, you have to use each find command twice.

First, have it look for

^Report Type:

(and add a space after that), and apply your Type style in the Change To field. Then repeat the same Find, but this time do not apply any formatting, so it will delete the text. Doing everything twice manually is a bore, but the FindChangeByList script won't mind.

9:48 am
February 4, 2012


jessereko

Member

posts 21

Would this work?

find:

(Report Type: )(.+)

replace:

$2 

and apply paragraph style.

12:55 pm
February 5, 2012


Jongware

Member

posts 764

Jesse, I think it would! But better put the ^ "Start of Paragraph" at the beginning, just to make sure it will only remove the right text.

(Sure, there is little chance that particular text may occur inside a sentence, but better make it double-safe!)

11:00 am
February 7, 2012


tabaholic

Member

posts 24

Hi guys,

I can figure out how to the FindChangeList.txt file to change text but not apply a paragraph style. :(

I am stuck on your above note "apply your Type style in the Change To field."

I have tried every combination of change and/or apply I can think of.


text {find what:"Report Title: " } {change to: ""} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}


thanks for any insite.

I will keep trying…