Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Generating links from "filename.htm" plain text?

Reply
Thread Tools

Generating links from "filename.htm" plain text?

 
 
Phillip Roncoroni
Guest
Posts: n/a
 
      01-08-2004
I'll hopefully be putting an archive of about 5,000 old html pages I've
collected over the years on my website, for people to search thru, and
Google to index.

I generated a directory listing with:
copy *.htm c:\archive >>c:\log.txt

Now I have a log of:
pg1.htm
pg2.htm
pg3.htm

etc. but with their real filenames, and 5,000+ of them, in plain text, one
per line.

Is there a way to turn each of these filenames into a clickable link without
having to do it manually?

Thanks in advance.

--

goodcow
goodcowfilms.com


 
Reply With Quote
 
 
 
 
Leif K-Brooks
Guest
Posts: n/a
 
      01-08-2004
Phillip Roncoroni wrote:
> Now I have a log of:
> pg1.htm
> pg2.htm
> pg3.htm
>
> etc. but with their real filenames, and 5,000+ of them, in plain text, one
> per line.
>
> Is there a way to turn each of these filenames into a clickable link without
> having to do it manually?


Perl.

use strict;
use warnings;
open(FILE_LOG, "c:\\log.txt");
print "<ul>\n";
while (my $file = <FILE_LOG) {
print "<li><a href=\"$file\">$file</a></li>\n";
}
print "</ul>\n";

 
Reply With Quote
 
 
 
 
Phillip Roncoroni
Guest
Posts: n/a
 
      01-08-2004
"Leif K-Brooks" <(E-Mail Removed)> wrote in message
news:vQ1Lb.151$(E-Mail Removed)...
> Phillip Roncoroni wrote:
> > Now I have a log of:
> > pg1.htm
> > pg2.htm
> > pg3.htm
> >
> > etc. but with their real filenames, and 5,000+ of them, in plain text,

one
> > per line.
> >
> > Is there a way to turn each of these filenames into a clickable link

without
> > having to do it manually?

>
> Perl.
>
> use strict;
> use warnings;
> open(FILE_LOG, "c:\\log.txt");
> print "<ul>\n";
> while (my $file = <FILE_LOG) {
> print "<li><a href=\"$file\">$file</a></li>\n";
> }
> print "</ul>\n";
>


Now how exactly do I run this, as I have no idea how to use Perl...

--

goodcow
goodcowfilms.com


 
Reply With Quote
 
Hunter
Guest
Posts: n/a
 
      01-08-2004

"Phillip Roncoroni" <(E-Mail Removed)> wrote in message
news:iZ1Lb.34301$(E-Mail Removed)...
> "Leif K-Brooks" <(E-Mail Removed)> wrote in message
> news:vQ1Lb.151$(E-Mail Removed)...
> > Phillip Roncoroni wrote:
> > > Now I have a log of:
> > > pg1.htm
> > > pg2.htm
> > > pg3.htm
> > >
> > > etc. but with their real filenames, and 5,000+ of them, in plain text,

> one
> > > per line.
> > >
> > > Is there a way to turn each of these filenames into a clickable link

> without
> > > having to do it manually?

> >
> > Perl.
> >
> > use strict;
> > use warnings;
> > open(FILE_LOG, "c:\\log.txt");
> > print "<ul>\n";
> > while (my $file = <FILE_LOG) {
> > print "<li><a href=\"$file\">$file</a></li>\n";
> > }
> > print "</ul>\n";
> >

>
> Now how exactly do I run this, as I have no idea how to use Perl...
>


Hi Philip -

If you have telnet or ssh access to your server then ftp your file to the
server.
Then use an editor like vi to populate the file. Here are your steps:

ftp file to server
telnet to server and go to the path where you uploaded the file
vi addlinks.pl
be sure to add your perl path - *usually* #!/usr/bin/perl (if it's not there
just type 'which perl')
copy the script above into addlinks.pl removing the c:\\
chmod 755 addlinks.pl
then from the command line type: ./addlinks.pl log.txt

hth, david


--------------------------------------------------
Exceptional Gift Baskets Online!
http://cranberrycorners.ca/home.shtml


 
Reply With Quote
 
Hunter
Guest
Posts: n/a
 
      01-08-2004

"Hunter" <(E-Mail Removed)> wrote in message
news:Xz3Lb.27394$(E-Mail Removed) le.rogers.com...
>
> "Phillip Roncoroni" <(E-Mail Removed)> wrote in message
> news:iZ1Lb.34301$(E-Mail Removed)...
> > "Leif K-Brooks" <(E-Mail Removed)> wrote in message
> > news:vQ1Lb.151$(E-Mail Removed)...
> > > Phillip Roncoroni wrote:
> > > > Now I have a log of:
> > > > pg1.htm
> > > > pg2.htm
> > > > pg3.htm
> > > >
> > > > etc. but with their real filenames, and 5,000+ of them, in plain

text,
> > one
> > > > per line.
> > > >
> > > > Is there a way to turn each of these filenames into a clickable link

> > without
> > > > having to do it manually?
> > >
> > > Perl.
> > >
> > > use strict;
> > > use warnings;
> > > open(FILE_LOG, "c:\\log.txt");
> > > print "<ul>\n";
> > > while (my $file = <FILE_LOG) {
> > > print "<li><a href=\"$file\">$file</a></li>\n";
> > > }
> > > print "</ul>\n";
> > >

> >
> > Now how exactly do I run this, as I have no idea how to use Perl...
> >

>
> Hi Philip -
>
> If you have telnet or ssh access to your server then ftp your file to the
> server.
> Then use an editor like vi to populate the file. Here are your steps:
>
> ftp file to server
> telnet to server and go to the path where you uploaded the file
> vi addlinks.pl
> be sure to add your perl path - *usually* #!/usr/bin/perl (if it's not

there
> just type 'which perl')
> copy the script above into addlinks.pl removing the c:\\
> chmod 755 addlinks.pl
> then from the command line type: ./addlinks.pl log.txt
>


Hi Philip - I made an error on the last step. It should just be
../addlinks.pl (without the filename)

If you need a hand you can mail me at http://www.velocityreviews.com/forums/(E-Mail Removed)


 
Reply With Quote
 
Disco Octopus
Guest
Posts: n/a
 
      01-08-2004
Phillip Roncoroni wrote:
> I'll hopefully be putting an archive of about 5,000 old html pages
> I've collected over the years on my website, for people to search
> thru, and Google to index.
>
> I generated a directory listing with:
> copy *.htm c:\archive >>c:\log.txt
>
> Now I have a log of:
> pg1.htm
> pg2.htm
> pg3.htm
>
> etc. but with their real filenames, and 5,000+ of them, in plain
> text, one per line.
>
> Is there a way to turn each of these filenames into a clickable link
> without having to do it manually?
>
> Thanks in advance.


put all your files in one folder, then run this at your command line.....

<commandline>
FOR /F "usebackq delims==" %i IN (`dir /b`) DO @echo "<a href=%i>%i</a><br>"
>> allfiles.html

</commandline>

you will now have a file called allfiles.html






 
Reply With Quote
 
Jan Faerber
Guest
Posts: n/a
 
      01-08-2004

> Is there a way to turn each of these filenames into a clickable link
> without
> having to do it manually?





Maybe you can use a simple search & replace tool.


Jan
 
Reply With Quote
 
Toby A Inkster
Guest
Posts: n/a
 
      01-08-2004
Leif K-Brooks wrote:

> while (my $file = <FILE_LOG) {
> print "<li><a href=\"$file\">$file</a></li>\n";
> }


<FILE_LOG should have a closing >.

You should probably make use of chomp too.

use strict;
use warnings;
open(FILE_LOG, "c:\\log.txt");
print "<ul>\n";
while (my $file = <FILE_LOG>) {
chomp $file;
print "<li><a href=\"$file\">$file</a></li>\n";
}
print "</ul>\n";

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?page=132

 
Reply With Quote
 
Leif K-Brooks
Guest
Posts: n/a
 
      01-08-2004
Toby A Inkster wrote:
> <FILE_LOG should have a closing >.
>
> You should probably make use of chomp too.


Yup, you're right. The first one is a typo, and the second was caused by
me not using Perl enough to remember things like that.

 
Reply With Quote
 
Phillip Roncoroni
Guest
Posts: n/a
 
      01-08-2004
"Hunter" <(E-Mail Removed)> wrote in message
news:y64Lb.27926$(E-Mail Removed) ble.rogers.com...
>
> "Hunter" <(E-Mail Removed)> wrote in message
> news:Xz3Lb.27394$(E-Mail Removed) le.rogers.com...
> >
> > "Phillip Roncoroni" <(E-Mail Removed)> wrote in message
> > news:iZ1Lb.34301$(E-Mail Removed)...
> > > "Leif K-Brooks" <(E-Mail Removed)> wrote in message
> > > news:vQ1Lb.151$(E-Mail Removed)...
> > > > Phillip Roncoroni wrote:
> > > > > Now I have a log of:
> > > > > pg1.htm
> > > > > pg2.htm
> > > > > pg3.htm
> > > > >
> > > > > etc. but with their real filenames, and 5,000+ of them, in plain

> text,
> > > one
> > > > > per line.
> > > > >
> > > > > Is there a way to turn each of these filenames into a clickable

link
> > > without
> > > > > having to do it manually?
> > > >
> > > > Perl.
> > > >
> > > > use strict;
> > > > use warnings;
> > > > open(FILE_LOG, "c:\\log.txt");
> > > > print "<ul>\n";
> > > > while (my $file = <FILE_LOG) {
> > > > print "<li><a href=\"$file\">$file</a></li>\n";
> > > > }
> > > > print "</ul>\n";
> > > >
> > >
> > > Now how exactly do I run this, as I have no idea how to use Perl...
> > >

> >
> > Hi Philip -
> >
> > If you have telnet or ssh access to your server then ftp your file to

the
> > server.
> > Then use an editor like vi to populate the file. Here are your steps:
> >
> > ftp file to server
> > telnet to server and go to the path where you uploaded the file
> > vi addlinks.pl
> > be sure to add your perl path - *usually* #!/usr/bin/perl (if it's not

> there
> > just type 'which perl')
> > copy the script above into addlinks.pl removing the c:\\
> > chmod 755 addlinks.pl
> > then from the command line type: ./addlinks.pl log.txt
> >

>
> Hi Philip - I made an error on the last step. It should just be
> ./addlinks.pl (without the filename)
>
> If you need a hand you can mail me at (E-Mail Removed)
>
>


Thanks, but I managed to get somebody else with a Unix box to just run the
script for me with the file listing in question.

--

goodcow
goodcowfilms.com


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FF Crashes on Links within Links Puma Firefox 10 02-17-2009 07:12 PM
[XSL] generating links to chapter, header, subheaders with autonumeration jszczepankiewicz@gmail.com XML 3 03-06-2007 11:08 AM
Make A Shorter Link - no new links accepted, old links still work. why? Computer Support 7 01-02-2007 09:45 PM
Site Links and Physical WAN Links =?Utf-8?B?RW5mb1BhdWw=?= MCSE 2 03-22-2005 09:23 AM
Exchange Links < Western Cartoon Cards > Exchange Links www.westerncartooncards.ca HTML 2 07-12-2004 07:59 PM



Advertisments