Hi,
I am wondering if it is possible to do multiple search/replace actions in a document. What I am needing to do is the following:
Designers export xHTML from InDesignCS3, but this HTML needs some brushing up.
InDesign exports:
And I need to replace it with:
The table1 name is a variable. One document can have multiple table class names.
Is there a way to script this, and can anyone point me in the right direction?
Cheers!
I really like sed, and use this constantly to make replacements.
heres an example of how i would use it.
on sed(s, reg)
do shell script "echo " & quoted form of s & " | sed " & quoted form of reg & " "
end sed
set str to "AAA<table class=\"table1\">AADFADSFa"
sed(str, "s/<table class=\"table1\">/<table class=\"table1\" cellspacing=0 cellpadding=0>/g")
Thanks so much for your reply. From what I understand this script will do what I want, but then only for the ‘table1’ variation of my class. What I am looking for is a script that can replace:
with
Again,
Thanks so much… sed is not a utility I am familiar with 
Well,
a good friend of mine knew more about sed then myself… He created this sh-script:
#!/bin/bash
for file in *.html; do
sed -i .orig 's/<table class="\(.*\)"\(.*\)>/<table class="\1"\2 cellspacing="0" cellpadding="0">/g' $file
done
Any idea how I fit this into AppleScript? The thing is that this script also makes a copy of the original file (names it .orig) and then does the find/replace action.
cheers
Try something like this:
choose file with prompt "Find and replace text in these files:" with multiple selections allowed without invisibles
repeat with thisItem in result
do shell script "/usr/bin/sed -i .orig 's/<table class=\"\\(.*\\)\"\\(.*\\)>/<table class=\"\\1\"\\2 cellspacing=\"0\" cellpadding=\"0\">/g' " & quoted form of POSIX path of thisItem
end repeat
Hmm, somehow I end up with an empty document this way 
well, strangeness. I end up with an empty document all the time. Tried to run in Script Editor and saving as an application