Urban Legends Reference Pages*http://209.176.31.25/snopes/
Boston Sidewalk Today*http://boston.sidewalk.com/
Yahoo! Autos*http://autos.yahoo.com/
I want to convert each line of the text file into a distinct *.URL file
that will function as a Favorite in Internet Explorer. For a file
named Yahoo! Autos.url, for example, I think the following content will
suffice:
[InternetShortcut]
URL=http://autos.yahoo.com/
How can I accomplish this conversion?
> For which OS?
Questions relating to Windows NT/W2K/XP etc are more appropriate in
<news:alt.msdos.batch.nt>
or
<news:microsoft.public.win2000.cmdprompt.admin>
If it's NTish windows then this batch file works here under XP:
@echo off
for /f "tokens=1* delims=*" %%a in (file.txt) do (
>"%%a.url" echo [InternetShortcut]
>>"%%a.url" echo URL=%%b
)
For which OS?
Meanwhile, new Favorites - and then Bookmarks, as I transitioned to
Firefox - continued to accumulate. Along with the chaos came the
realization that I would rather have these convenient links within my
browser, not on a separate web page. What I would have to do, I
decided, was to get all of my links back to *.URL format, readable by
Internet Explorer. Then I could import them into Firefox and use an
appropriate extension to sort them.
I suspected there were freeware programs out there, somewhere, that
would automate at least the first step of this process, but I was not
having much luck finding them. Nor was I entirely prepared to have the
process handled automatically. To some extent, I wanted to fondle my
old bookmarks, to see what I had been doing without all these years. I
was also curious; in part, I just wanted to see if I could do this
conversion manually.
To manually convert the HTML references, I began by using the View >
Page Source in Firefox. (Bear with me here: I am no longer certain
whether that menu pick is a native feature of Firefox or is added to my
system, instead, through some kind of extension.) I pasted the HTML
into Notepad, deleted the introductory and conclusory HTML codes, and
did a search-and-replace to eliminate the "<a href=" code appearing
at the start of each link line.
With that done, I could paste the result into Excel without having
Excel automatically convert each piece of HTML back into webpage
format. I dimly recall that there might be a way to tell Excel not to
bother, but that technique wasn't coming to my recollection at the
moment, so I used this approach instead. Then, in Excel, I used a
series of MID and FIND formulas and search-and-replace operations to
strip out the remaining unnecessary codes, and also to separate the URL
from its name. I also had to do some search-and-replace operations to
make sure none of these future file names contained forbidden
characters ( \ / : * ? < > | ); and I wrote some formulas to check the
sorted table for duplicates. Thus, for example, I wound up with the
name, "CNN.com," accompanied by its URL, "http://www.cnn.com."
What I wanted, then, was to convert each line of the spreadsheet,
containing two columns with those name and URL entries, into its own
distinct Favorite link file. The content of a URL file, for my
purposes, was like this:
[InternetShortcut]
URL=http://www.cnn.com/
where the name of that particular file would be CNN.com.url. The part
that I didn't know how to do was to extract the URL from the second
column of my spreadsheet, and stick it into a file with the name
provided in the first column of my spreadsheet. Of course, I could
output the contents of the spreadsheet in different formats (e.g.,
text); but what format did I need?
I thought I might be competent to use one of three different methods
for that conversion from spreadsheet to URL file. First, it seemed
there might be some piece of freeware that would do the whole thing.
Second, I thought I might be able to do it all from within Excel.
Third, if I put it into a text file, I was pretty sure there would be a
way to do it with DOS batch commands.
Seeking the approach that would work best for me, given my limited
expertise in these things, I wrote up the problem in three different
ways, appropriate to the respective forum, and posted it at the
following locations:
alt.comp.freeware:
http://tinyurl.com/rzp7k
microsoft.public.excel.misc:
http://tinyurl.com/qkp5l
alt.msdos.batch:
http://tinyurl.com/ro7pe
(If those links fail at some point, hopefully the future reader (which
will most likely be me) can find the appropriate pages by searching for
some key words from this posting.)
The outcome of this effort was to draw helpful attention from three
different perspectives on the problem. I appreciated the help, and I
said so.
In response to the first approach, there did not seem to be any
freeware that was right on target.
In response to the second approach, although I am pretty comfortable
with Excel for general purposes, I have never mastered its macro
language. Somehow I got spoiled by Lotus 1-2-3, back in the 1980s, and
ever since I have been hoping that a similarly easy and flexible
approach to macros would emerge in Excel. Perhaps, someday, it will.
But for this project, I was not sure how to apply the macro advice I
received.
The solution that seemed most elegant, and the one with which I was
most comfortable, was the third one, from alt.msdos.batch. That
solution was to use Notepad to create a *.BAT file with these contents:
@echo off
for /f "tokens=1* delims=*" %%a in (FILE.TXT) do (
>"%%a.url" echo [InternetShortcut]
>>"%%a.url" echo URL=%%b
)
where FILE.TXT was my asterisk-delimited text file, each line of which
contained something like this: Yahoo! Autos*http://autos.yahoo.com/
This approach gave me my thousands of distinct Favorites. I put them
into the appropriate Internet Explorer folder and imported them into
Firefox, and am now slaving away at the process of sorting them into
categories.
I am posting this summary of the solution in this alt.msdos.batch
forum, partly because this is where I found the answer, and partly
because nobody else will know what I am talking about. My apologies
for the length of the explanation. I only do this every once in a
while. I hope the elaboration will be helpful to someone. If anyone
cares to mention other ways in which I might have solved this problem,
or if this presentation triggers other questions, I hope to hear them.
Thanks, again, for the help.
Ray
snip...
> The solution that seemed most elegant, and the one with which I was
> most comfortable, was the third one, from alt.msdos.batch. That
> solution was to use Notepad to create a *.BAT file with these contents:
>
> @echo off
> for /f "tokens=1* delims=*" %%a in (FILE.TXT) do (
>
> >"%%a.url" echo [InternetShortcut]
> >>"%%a.url" echo URL=%%b
>
> )
>
> where FILE.TXT was my asterisk-delimited text file, each line of which
> contained something like this: Yahoo! Autos*http://autos.yahoo.com/
>
> This approach gave me my thousands of distinct Favorites. I put them
> into the appropriate Internet Explorer folder and imported them into
> Firefox, and am now slaving away at the process of sorting them into
> categories.
>
> I am posting this summary of the solution in this alt.msdos.batch
> forum, partly because this is where I found the answer, and partly
> because nobody else will know what I am talking about. My apologies
> for the length of the explanation. I only do this every once in a
> while. I hope the elaboration will be helpful to someone. If anyone
> cares to mention other ways in which I might have solved this problem,
> or if this presentation triggers other questions, I hope to hear them.
> Thanks, again, for the help.
There is not much incentive for others to even consider offering alternate
solutions to an already solved problem. Good luck.
--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)