Re: OMG SO CLOSE! Re: Please write me a simple multi-file text line replace script.



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' )
}

}
.



Relevant Pages

  • OMG SO CLOSE! Re: Please write me a simple multi-file text line replace script.
    ... I redid the album to work late at night by editing all html files by hand ... it is tantelizing and killing me. ... Put "messageforohmster" in message body ...
    (comp.unix.shell)
  • Bad Link HTML Files for Ben Here - Re: OMG SO CLOSE! Re: Please write me a simple multi-file
    ... all with jpg images in them and ran "album -theme DropColor". ... they have sub dirs in them for different colors. ... html files that the album created, ALL with bad and unusable paths to the ...
    (comp.unix.shell)
  • Re: Incorrect content shown on CD
    ... Just to step back - are you editing the CD or the ripped tracks? ... If you are editing the tracks, make sure you edit both the Artist and Album ... See http://zachd.com/pss/pss.html for some helpful WMP info. ...
    (microsoft.public.windowsmedia.player)
  • Re: Incorrect content shown on CD
    ... When I attempt to edit the CD I've chosen Find ... Just to step back - are you editing the CD or the ripped tracks? ... right-click on that and choose Find Album Info. ...
    (microsoft.public.windowsmedia.player)
  • Re: U2 Mgr. Blames Hippie Deadheads
    ... mainly because of the lack of editing. ... great single album, stretching it into a double album was a mistake. ... the world according to RMGD. ... This just in...one of the greatest albums of all time sucks, ...
    (rec.music.gdead)