Re: OMG SO CLOSE! Re: Please write me a simple multi-file text line replace script.
- From: w_a_x_man <w_a_x_man@xxxxxxxxx>
- Date: Wed, 13 Oct 2010 11:23:47 -0700 (PDT)
On Oct 13, 12:19 pm, Ohmster <r...@xxxxxxxxxxxxxxx> wrote:
We start out with all pages generated uising this .css page information
which is NO GOOD:
<link rel="stylesheet" type="text/css"
href="../../../../usr/share/album/themes/DropColor/framecss.css"
title="Framecss album style" />
And want to end up with framecss.css in top level album, ../framecss.css
in second level directory, and so forth.
On Oct 13, 11:00 am, Ohmster <r...@xxxxxxxxxxxxxxx> wrote:
Ed Morton <mortons...@xxxxxxxxx> wrote innews:i94938$atv$1@xxxxxxxxxxxxxxxxxxxxxxxxxx:
Ed Morton on comp.umix.awk (is that right?
Close, it's comp.lang.awk.
-- anywy, the major
awk group, could probably whip up an awk script that would do the
job.
Thanks for the referral! Since this is a simple substitution on a
single line, though, I'd just use sed for it and then you can also
take advantage of GNU sed's "-i" option if it's available to you. See
Dave Gibson's response.
Regards,
Ed.
Dear Ed and Sid,
Thank you so much for pointing me in the right direction. I did save all
messages and will try them, so far Dave has come SO CLOSE to perfection
that I must step up to the plate and take the blame for it not being 100%
perfect. It was late, I was tired, and I left out a super important
fact/requirement of the script. Now that I have tried Dave's script I
realize it and here it is:
Since the album software is recursive and can include subdirectories, I
neglected to tell you that every time we go down one
level into the album_directory, we need to indicate this on the css file
as follows:
Top level: href="framecss.css"
1st level subdirectory, including the thumbnail subdirectory that the
album itself creates: href="../framecss.css"
2nd level subdirectory: href="../../framecss.css"
Etc., so on, and so forth. Oh man I did not even realize the depth of
this situation myself. I did the editing by hand and was frustrated after
doing 40 html files, now I see I have *way* more to edit by hand and this
will kill me.
I was *very* disappointed in that the final album made these huge
pictures that I could not control and the original album did not do this,
each picture had it's own html page that controlled this. Now I realize
that I neglected to edit out that final 3rd level subdirectory of html
files which require editing. This means that the script, if fixed, will
save hand editing hundreds of html files and will make using the album
software a genuine possibility. I will probably send the results of all
this to the author, David Ljung Madison, at marginalhacks.com. He
wrote a fantastic bit of software and released it to the public and
deserves the praise he should get, and possibly a small donation to help
fund his work. I am a very poor person, (currently unemployed but for the
computer work I do) however, I do believe in the open source software
movement and am willing to show my support where it counts.
Thank you boys, somebody please help get this straightened out, it would
mean so much and I need it desperately and must admit that this is *way*
over my head.
--
~Ohmster | ohmster59 /a/t/ gmail dot com
Put "messageforohmster" in message body
(That is Message Body, not Subject!)
to pass my spam filter.
Save this Ruby program in a file named "fix-hrefs.rb" and
run it in the proper directory this way:
ruby /path/fix-hrefs.rb
PATTERN =
%r{(<link[^<>]*\shref=")[^"]*(framecss.css"[^<>]*>)}
files = Dir[ "**/*.html" ].select{|x| File.file? x}
files.each{|file|
depth = file.split( "/" ).size - 1
replacement = "../" * depth
contents = IO.read( file )
open( file, "w" ){|f|
f.print contents.gsub( PATTERN,
'\1' + replacement + '\2' )
}
}
.
- Follow-Ups:
- References:
- Re: Please write me a simple multi-file text line replace script.
- From: Dave Gibson
- OMG SO CLOSE! Re: Please write me a simple multi-file text line replace script.
- From: Ohmster
- Re: OMG SO CLOSE! Re: Please write me a simple multi-file text line replace script.
- From: Ben Bacarisse
- Re: OMG SO CLOSE! Re: Please write me a simple multi-file text line replace script.
- From: Ohmster
- Re: Please write me a simple multi-file text line replace script.
- Prev by Date: Re: OMG SO CLOSE! Re: Please write me a simple multi-file text line replace script.
- Next by Date: Re: OMG SO CLOSE! Re: Please write me a simple multi-file text line replace script.
- Previous by thread: Re: OMG SO CLOSE! Re: Please write me a simple multi-file text line replace script.
- Next by thread: Re: OMG SO CLOSE! Re: Please write me a simple multi-file text line replace script.
- Index(es):
Relevant Pages
|