Question: AppleScript for find & replace for multiple files with same values, but different predefined text values?
I create duplicates of certain RTFD documents, and I'm trying to figure out the best way to efficiently find and replace three discrete values in a set of duplicated documents, namely: office name, sub-office name, and contact info (in a paragraph block).
I’m not doing a batch find & replace of multiple files with the same values; rather, I’m trying to Find the same values, and Replace different saved predefined text values depending on whom I addressing (e.g. files addressed to the Dept. of Treasury should contain that agency name, the corresponding sub-agency name, like IRS, and its address/contact info).
I'm seeking an AppleScript (or something similar) that would enable me to carry out the following steps:
(1) Select and/or open list of selected files;
(2) Select and/or open the first file in the list;
(3) Search for a string or a regex pattern (e.g., TK-Agency or TK-Sub-Agency or TK-Contact_Info) for the first, selected / opened file in that list;
(4) Select a set of values (ideally relational, but stand alone is fine) -- that I can store / save somewhere to REPLACE the TK values in #3 with actual values (e.g., TK-Agency -> Dept. of Treasure , TK-Sub-Agency -> IRS , TK-Contact_Info -> IRS Headquarters Building, 1111 Constitution Avenue Northwest, Washington, District of Columbia, DC 2001)
(5) Save file after replacement -- while while retaining the integrity of the RTFD files (which has specific formatting that I have to maintain);
(6) De-select and/or close file;
(7) Select and/or open next file in the list of selected files;
I'm a newbie to AppleScript, and would greatly appreciate any suggestions.
Many thanks for your help!