[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
On Thursday 26 July 2007 20:43, Jonathan Roberts wrote:
> Hi all,
>
> I have a load of HTML files and I want to add the same text to the
> <head> section of all of them: is there any way I can add it
> automatically?! sed perhaps?
>
> Best wishes,
>
> Jon
Its potentially a tricky one but assuming you have 'good' quality HTML in the
files you could get it done relatively easily.
You'll need something that understands the DOM (Document Object Model).
a rough outline would be:
------------
for each html file in directory
new dom=file.read
headElement=dom.findelement("HEAD")
headElement.append("<br>Text to append")
file.write(dom)
next
----------
in the language of your choice
Tom te tom te tom
--
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html