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.
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?
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 & " "
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:
Thanks so much… sed is not a utility I am familiar with
a good friend of mine knew more about sed then myself… He created this sh-script:
for file in *.html; do
sed -i .orig 's/<table class="\(.*\)"\(.*\)>/<table class="\1"\2 cellspacing="0" cellpadding="0">/g' $file
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.
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
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