1 Reply Latest reply on Dec 23, 2010 1:54 AM by joesickspack

    Difficult (?) find and replace. AppleScript, ID CS4

    joesickspack

      I have a catalog in which product descriptions are structured something like this:

       

      Paragraph Style A

      Paragraph Style B

      Paragraph Style C

      Paragraph Style D

       

      but some products are like this:

       

      Paragraph Style A

      Paragraph Style B

      Paragraph Style D

       

      I want to insert a blank Paragraph Style C before Paragraph Style D for all products that are missing Paragraph Style C.

       

      There are sometimes consecutive paragraphs with Style B, but there is never more than one paragraph with Style D, so the script has to look for the Style D paragraphs and then insert the Style C paragraph before that.

       

      In addition I have to do some Find and Replace operations:

       

      1) FInd the first instance of a period in every Paragraph Style A and replace with a tab

       

      2) Find the first instance of an open parenthesis in every group of consecutive paragraphs of Style B and replace with a tab.

       

      So, if a product description was like this:

       

      Paragraph Style A

      Paragraph Style B

      Paragraph Style B

      Paragraph Style B

      Paragraph Style C

      Paragraph Style D

       

      the script would only find the first open parenthesis in the first Paragraph Style B and then move on to the next product.

       

      I am using AppleScript, ID CS4