From: Ohmster on
I've got a friend who is an artist and I made a nice website for him and
hosted it with his own domain on godaddy. One of the things he likes to
do with his website, aside from promoting his artwork for sale, is to
share culture and art links with all of his guests. From time to time, he
will give me URLs to add to the Links page on his site and I am happy to
do that for a good customer. I don't charge for stuff like that.

But this man now gives me a DVD full of desktop shortcuts, 111 of them
plus 3 zip files containing even more desktop shortcuts. I have no idea
of how to extract a list of URLS out of these desktop shortcuts other
than to click each one in Windows, then copy the URL from the browser
address bar, and then paste it into a text or html list, rinse and
repeat. I do not mind doing this for 2 or 3 shortcuts, but for hundreds
of them? No way, would take too long and he will no doubt come back with
more.

I have a nice Fedora 12 server networked to my computer where I test
websites and serve up my own domain. Linux is a very rich scripting
evironment, however, I do not have a good enough working knowledge of
shell, perl, python, cgi, or any other scripting language to know how to
do this. Can somebody help me please come up with a script that will take
all desktop shortcuts in a directory, process each one, and add the URL
inside to an ongoing list, prefereably clickable html, although plain
text would be alright? No, this is not homework or anything like that,
this is a real world situation and I just do not have the skill to get it
done. Stanley C. Kitching once helped me out with a dandy python script
that would take a text FAQ and turn it into a nice, clickable html
document with links and named anchors that would really work. A
magnificent work, thank you cousin Stanley, if you are still around my
friend.

Here is what one of the desktop shortcuts looks like so you will see what
needs to be done:

[DEFAULT]
BASEURL=http://www.lincart.com/
[InternetShortcut]
URL=http://www.lincart.com/
IDList=
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2

or another one:

[DEFAULT]
BASEURL=http://www.byroncoons.com/
[InternetShortcut]
URL=http://www.byroncoons.com/
IDList=
IconFile=http://www.byroncoons.com/favicon.ico
IconIndex=1
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2

The filenames on these things all have spaces in them too, although I
have a bulk file renamer that can change the spaces to underscores if
needed. Here is a sample listing of files (I have UNIX for Windows
installed on Windows 7 so that ls works,)

C:\Users\Paul\Documents\PaulsPCWorks\Customers\Jean_Claude_Boutrouille
\Links_03-15-2010>ls
AbsoluteArts.com.url
Art Calendar.url
Art-Jean Claude Arts.url
ArtJean Claude Boutrouille -.url
Artnet -.url
Artspan.url
Artspan.zip
Boca Raton -EXOR.url
Boca Raton -Elaine Baker (2).zip
Boca Raton -Elaine Baker.url
Boca Raton -Elaine Baker.zip
Boca Raton -Karen Lynne Gallery.url
Boca Raton -Kevin McPherrin.url
Boca Raton -Rosenbaum Contemporary.url
Boca Raton -Schuyler.url
Boca Raton -Sundook Fine Art.url
Boca Raton-Addison Gallery.url
Boca-Janeris Photography.url
Canada-Galerie Simon Blais.url
Canada-Landau Fine Art.url
Charleston-Eva Carter.url
China - Art Galleries - Beijing.url
China-10 Chancery Lane Gallery.url

Can anybody help with a scripting language or a simple script that will
do the things I want done with these files?

Take URL out of each desktop shortcut file and put it in an ongoing list,
process each shortcut, adding the URL to the list, until all shorcuts are
processed and we now have a final list of all the URLs in the shortcuts.
A clickable html list would be a big plus, however a plain text list
would work fine.

Thank you!

--
~Ohmster | ohmster59 /a/t/ gmail dot com
Put "messageforohmster" in message body
(That is Message Body, not Subject!)
to pass my spam filter.
From: John Hasler on
Create a directory and put all the "shortcuts" it. You'll have to unzip
the zips yourself. Make sure all the filenames end in ".url". Don't
worry about the spaces. Then run this (untested) command in the
directory:

grep '^URL=http://' *.url | cut -f2 -d= > urls

This will put a list of URLs in the file "urls". Do you want the
filename associated with each URL?
--
John Hasler
jhasler(a)newsguy.com
Dancing Horse Hill
Elmwood, WI USA
From: Bit Twister on
On Mon, 15 Mar 2010 19:24:20 -0500, Ohmster wrote:
> I have no idea
> of how to extract a list of URLS out of these desktop shortcuts other

You can use grep for extraction.
>
> Here is what one of the desktop shortcuts looks like so you will see what
> needs to be done:
>
> [DEFAULT]
> BASEURL=http://www.lincart.com/
> [InternetShortcut]
> URL=http://www.lincart.com/
> IDList=
> [{000214A0-0000-0000-C000-000000000046}]
> Prop3=19,2

So, your script does something like
cd /location/of_shortcuts
grep BASEURL= * > urls.txt
creates your html header then
loops through the urls.txt file and splits line into words using =
as separator, output the url with whatever html you like.

For extra points, read http://tldp.org/LDP/abs/html/index.html

Untested kludge follows:

_out_fn=urls.html
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<!-- save as index.html -->
<!-- Enter file:$PWD in browser Location: -->
<HTML>
<HEAD>
<TITLE>Local Home Page $PWD</TITLE>
<TR>
<!-- Background wheat, links blue (unvisited), navy (visited), red (active) -->
<BODY
BGCOLOR="Wheat"
LINK="Blue"
VLINK="Red"
ALINK="Green"
TEXT="Black"
<H4 ALIGN="CENTER">
$PWD
" > $_out_fn

grep BASEURL= * > urls.txt

while read -r _line ; do
set -- $(echo $_line)
echo "<TD><A href=\"$2\">$2</A></TD>" >> $_out_fn
done < urls.txt

echo "
</TR>
</h1>
</BODY>
</HTML>
" >> $_out_fn

echo "Output in $_out_fn"
From: Bit Twister on
On Tue, 16 Mar 2010 01:22:00 +0000 (UTC), Bit Twister wrote:
> On Mon, 15 Mar 2010 19:24:20 -0500, Ohmster wrote:
>> I have no idea
>> of how to extract a list of URLS out of these desktop shortcuts other
>

oops: forgot to set separator.

_out_fn=urls.html
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<!-- save as index.html -->
<!-- Enter file:$PWD in browser Location: -->
<HTML>
<HEAD>
<TITLE>Local Home Page $PWD</TITLE>
<TR>
<!-- Background wheat, links blue (unvisited), navy (visited), red (active) -->
<BODY
BGCOLOR="Wheat"
LINK="Blue"
VLINK="Red"
ALINK="Green"
TEXT="Black"
<H4 ALIGN="CENTER">
$PWD
" > $_out_fn

grep BASEURL= * > urls.txt

while read -r _line ; do
set -- $(IFS='=' ; echo $_line)
echo "<TD><A href=\"$2\">$2</A></TD>" >> $_out_fn
done < urls.txt

echo "
</TR>
</h1>
</BODY>
</HTML>
" >> $_out_fn

echo "Output in $_out_fn"
From: Ohmster on
Bit Twister <BitTwister(a)mouse-potato.com> wrote in
news:slrnhptne1.3cu.BitTwister(a)cooker.home.test:

> On Tue, 16 Mar 2010 01:22:00 +0000 (UTC), Bit Twister wrote:
>> On Mon, 15 Mar 2010 19:24:20 -0500, Ohmster wrote:
>>> I have no idea
>>> of how to extract a list of URLS out of these desktop shortcuts
>>> other
>>
>
> oops: forgot to set separator.


Oh thank you so much Bit Twister. You have been at the help desk for
practically my entire life and I have gotten dammed good help from you on
many, many occasions. Thank you my friend. Of course I want to pick the
script apart and learn it, but I am very tired right now, (Was falling
asleep at work at the computer) and need to get this done. I promise to
follow up and understand this and will take you up on the extra points
from LDAP, but for now, I need a working script. So are you saying that I
need to copy and paste what is between these dotted line separators into
a text file with vim and execute it? Do I need to put "#!/bin/bash" at
the top of it?

---------------------------------------------------------------------
_out_fn=urls.html
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<!-- save as index.html -->
<!-- Enter file:$PWD in browser Location: -->
<HTML>
<HEAD>
<TITLE>Local Home Page $PWD</TITLE>
<TR>
<!-- Background wheat, links blue (unvisited), navy (visited), red
(active) -->
<BODY
BGCOLOR="Wheat"
LINK="Blue"
VLINK="Red"
ALINK="Green"
TEXT="Black"
<H4 ALIGN="CENTER">
$PWD
" > $_out_fn

grep BASEURL= * > urls.txt

while read -r _line ; do
set -- $(IFS='=' ; echo $_line)
echo "<TD><A href=\"$2\">$2</A></TD>" >> $_out_fn
done < urls.txt

echo "
</TR>
</h1>
</BODY>
</HTML>
" >> $_out_fn

echo "Output in $_out_fn"
---------------------------------------------------------------------

That's it? Paste this into a file called geturls in vim, chmod it to 755,
and then execute it in the same directory as where all the desktop
shortcut files are? Do I need to prepare the desktop shortcut files in
any way such as give them all the same extension or remove spaces?

Thanks so much Bit, waiting on your reply.

--
~Ohmster | ohmster59 /a/t/ gmail dot com
Put "messageforohmster" in message body
(That is Message Body, not Subject!)
to pass my spam filter.