Got it!
find ./*.html -type f | xargs perl -p -i.orig -e \
's/bgcolor\=\"#FF6600\"([^\"]*)\"/background\=\"annafrac.JPG\"\ /gi'
Escape characters! duh!
I know it does stuff it doesnt need to, but it does replace
bgcolor="#FF6600"
to:
background="../annafrac.JPG"
Jamie
Sometime just before Monday 29 April 2002 10:07 pm Linux Rocks ! Wrote
about:[EUG-LUG:2477] Re: tool to convert links from absolute to relative?
: So... This is what I finally ended up with:
:
: find ./*.html -type f | xargs perl -p -i -e \ 'BEGIN {undef $/}
: s/alt\=\"([^\"]*)\"/alt="$1" title="$1"/gis'
:
: It only looks in the cwd for html files, adds title=<WhatEverIsInAltTag> to
: each img line. It doesnt check to see if the alt tag exists... (I couldnt
: get that one to work right!)
:
: anyway... its in my /usr/bin, so wherever I may happen to be, I just type
: a2t and it dups the alt tags to title tags... it might be nice to make it
: recursive too... but Im happy!
:
: So... Now I want to replace various things in each html file in a direfind
: ./*.html -type f | xargs perl -p -i -e \ 'BEGIN {undef $/}
: s/bgcolor="#FF6600"([^\"]*)\"/background="../annafrac.JPG"/gis'ctroy..... I
: tried
: to change:
: bgcolor="#FF6600"
: to:
: background="../annafrac.JPG"
:
: but it didnt work ofcourse...
: What I would like is a command line utility, that I can pass what I want
: changed, and what I want changed...
: ie: ChangeHtml bgcolor="#FF6600" background="../annafrac.JPG"
: or maybe
: ChangeHtml -i 'bgcolor="#FF6600"' -o 'background="../annafrac.JPG"'
:
: So... how to do your convert to relative (from absolute)... Thats abit
: trickier(sp?) huh... Well... maybe by just passing the URL you want
: stripped, so ... you could make one script for each domain...
: so... you have a script that looks for
: <a href="http://blah.com/path/file.name">
: strips out the "http://blah.com/"
: and leaves
: <a href="path/file.name">
:
: Isnt that do-able?
:
: Jamie
: Sometime just before Monday 29 April 2002 09:40 am Bob Miller Wrote
: about:[EUG-LUG:2472] tool to convert links from absolute to relative?
:
: : I have a copy of a web site. Nearly every link in it is an absolute
: : hard link, e.g., href="http://www.example.com/path/file.html" .
: : It is all static HTML.
: :
: : I got about 2/3 of the way through writing a perl script to change all
: : the links to relative form, so I can browse the site directly from
: : local files, and thought, "There must be a tool already written."
: :
: : So, who knows of a tool that will scan a directory of files (or even a
: : single file) and change all href and img src tags from absolute to
: : relative?
: :
: : Thanks...
--
for setting/changing your eug-lug mailinglist subscription use this website:
http://wWw.RockSolidNetworks.com/eug-lug.html
no microsoft products were used to produce this message.