AppleScript to find replace in all documents in folder

Hello-

did a quick search and could not find a solution to my query. :

After client files are submitted, we need to clean up the ‘styles’ that came out of inDesign. For example, a character style might be called ‘xyz-character-mainheadline-2columns’ and we need to switch that to ‘hedline’ to reflect the CSS style of where it’s going to, on the web. (We’re exporting indesign copy to html/xml).

So my thought to fix the hundreds of files that need reaming, line deletes etc., is to script a folder action, but i’d rather make a quick AppleScript that has a variety of instructions (all in one Script) that pulls all files, regardless of name, from a predetermined folder - say ‘WebFiles’, applies the changes, saves and closes it.

However, I’ve having problems with the AppleScript I recorded, only selecting the one article.

I’m using text wrangler to open up the files themselves.

Here’s my amateur code:

tell application “TextWrangler”
activate

select find window
replace "xxyz-character-mainheadline-2columns" using "hedline" searching in text 1 of text document "newsmaking_01" options {search mode:literal, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
select find window
close find window saving no
save text document 1
close text document 1 saving no

end tell

I’ll probably add a few requests of find/replace in the code, stacking them on top of each other, but any help in advance would be greatly appreciated. any other workaround suggestions are appreciated as well.

thank you.

Model: g5 dual 2.5
AppleScript: 2.21
Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)