here is a simple perl script to look inside every .html file in the directory specified ... scan for the <head> tag and then prints on a newline under it <script>insert your script here </script>
it creates a new file (ie. the orignal was test.html) with a .NEW suffix (ie. the new file would be called test.html.NEW). First test out the script, and if you like the results, edit the perl script or create a new one to delete all .html files and then rename .html.NEW to .html.
hope this helps
Usage: sreplace <file/directory>
edit: forgot to mention you will have to replace that top line as well with the directory of your perl program
edit2: the code window is screwing up <'s and >'s along with other characters. Here is the code in a non-formated window:
-------------------------------<BEGIN CUT HERE>--------------------------
#!/usr/local/bin/perl -w
die "Usage: sreplace <folder listing>" unless @ARGV == 1;
@files = `ls @ARGV`; #change this command on windows to `dir \b @ARGV` (I think)
@htmlfiles = grep(/\.html$/,@files);
foreach $file (@htmlfiles) {
print $file, "\n";
open(CUR, "$file");
open(OUT, "> $file.NEW");
while (<CUR>) {
if ($_ =~ /<head>/) {
print OUT $_;
print OUT "<script>insert script here</script>\n";
} else {
print OUT $_;
}
}
}