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.
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
jha...@newsguy.com
Dancing Horse Hill
Elmwood, WI USA
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"
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)
> 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?
---------------------------------------------------------------------
grep BASEURL= * > urls.txt
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.
> 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?
I would have clicked up a terminal
cat > geturls
Highlight from usenet reader, paste in the terminal, and hit
ctl d
Set permissions with
chmod +x geturls
> Do I need to put "#!/bin/bash" at
> the top of it?
If you like.
>
> 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?
Yep, looks good to me.
> Do I need to prepare the desktop shortcut files in
> any way such as give them all the same extension
That is why the grep did not specify file extension.
> or remove spaces?
Hey, try it and see if url in a spaced file name shows up in the
output file.
Frap, I just noticed, you need to change the " to \" in the colors section of
the header. :(
> 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?
Oh this is great, answers! And bit twister went so far as to give me
school on it, this is great, you guys rock man. Okay, first let's try out
John's command line to see if it works, preparing directory now...
(I don't care about the filename as to where the url came from, but thank
you for asking.)
...adding the url extension to all files in directory. I can use a
Windows file renamer but I wonder if I could do that with mv? Hmmm, when
in a Linux filesystem, these files ALL have the url extension, and I DO
NOT have the stupid "Hide known file extensions" box checked in Windows!
Now that really is odd, I wonder why Windows will not display that
extension in explorer? What about in a command window or with the Windows
version of ls? No, in a command window, all the files in Windows shows
the url extension, whether checking with dir, ls, or ls -la, they all
show the .url extension. Okay, onward and forward with John's test!
Wow! That worked a treat, just like that, BAM! ...and it was all done. No
output on the screen, no time processing the job, just bam and done.
Thank you very, very much. I need this bit of script so into my scripts
directory it goes. Now it will be fun to test and learn from Bit Twister.
Thank you John!
> 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?
This worked very well, thanks John, but it did get tripped up by at least
one of the urls. I am telling and showing you this not to complain, but
so that you can see what the error was and maybe how to fix it.
This URL file was not read properly.
[DEFAULT]
BASEURL=http://www.xanadugallery.com/Art/SubjectList.asp?Inventory
Category=3
[InternetShortcut]
URL=http://www.xanadugallery.com/Art/SubjectList.asp?Inventory Category=3
IDList=
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
That "Inventory Category=3" is actually all part of the URL and is
exactly how one has to visit that page to get the correct link. The
script returned this URL:
http://www.xanadugallery.com/Art/SubjectList.asp?Inventory Category
The "=3" part is missing from the harvested URL.
I am by no means "looking a gift horse in the mouth", but I thought that
you should know about it. I wonder if Bit Twister's it of madness will
fare any better? Oh this is such fun!
Apparently you want me to escape something with a backslash in the color
section of the script here:
<BODY
BGCOLOR="Wheat"
LINK="Blue"
VLINK="Red"
ALINK="Green"
TEXT="Black"
<H4 ALIGN="CENTER">
$PWD
" > $_out_fn
But what? What has to be escaped with the backslash Bit?
The " was to be escaped. :)
Saw the other post about category 3. Here try this one.
_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)
shift
echo "<TD><A href=\"$*\">$*</A></TD>" >> $_out_fn
> Hey, try it and see if url in a spaced file name shows up in the
> output file.
Wow, this is cool as hell Bit, but I am afraid it is too rough
around the edges to be used. If this were cleaned up to be functional, I
would love to have it, the thing looks so nice and all, but the output is
kind of screwy. Here is how it looks:
/home/ohmster/bench http://www.absolutearts.com/ Calendar.url:BASEURL
Claude Claude Claude Claude Claude -.url:BASEURL -.url:BASEURL
-.url:BASEURL http://www.artspan.com/ Photography.url:BASEURL Raton-
Addison Raton Raton Raton Raton Raton Raton Raton Raton Raton Simon Fine
Carter.url:BASEURL Chancery - Gallery.url:BASEURL Gallery.url:BASEURL
Gallery.url:BASEURL Blue Dickson.url:BASEURL Blick Bibby.url:BASEURL
Art.url:BASEURL Art Balderrama.url:BASEURL Klin.url:BASEURL
Klin.url:BASEURL Lauderdal-Art Lauderdale-ArtFusion.url:BASEURL
Lauderdale-Artists Lauderdale-Las Lauderdale-Max Richter.url:BASEURL
Dangereuses.url:BASEURL Dangereuses.url:BASEURL Zimmermann
Zimmermann.url:BASEURL Internationale BASEURL Museum Museum in Engelina
Artists.url:BASEURL Museums.url:BASEURL Kong
http://scorptest.free.fr/test_flip/
http://scorptest.free.fr/test_flip/JAPON/big.html Claude
Artarama.url:BASEURL Lillo-Beaufrand.url:BASEURL of Fine
Basel.url:BASEURL Art Steinbaum.url:BASEURL cisneros Rojas.url:BASEURL
Meirelles Snitzer.url:BASEURL Art Gallery Decorator.url:BASEURL
International Bruk Blossoms Savage Savage
http://www.nobe67art.com/index.html?page http://www.sun-sentinel.com/
Sentinel Sentinel Sentinel Americas York- York-Damien York_Franklin York-
York-John York-Marlborough York-PaceWildenstein.url:BASEURL York-
Sonnabend.url:BASEURL York-Sotheby's.url:BASEURL Beach-ARCATURE Beach-
GAVLAK.url:BASEURL Daniel Perrotin.url:BASEURL Morellet.url:BASEURL
Laurent Maria Soulages Design.url:BASEURL Dho.url:BASEURL
Milshtein.url:BASEURL Galler.url:BASEURL Blossoms Francisco-Byron
Francisco-Lincart.url:BASEURL Fe-Collector's Fe-Crowell.url:BASEURL Fe-
Hilario Fe-Jac Fe-Jack Fe-Karan Fe-LewAllen Fe-Nancy Fe-New Fe-Randall
Gallery.url:BASEURL -.url:BASEURL Dickson.url:BASEURL
http://www.xanadugallery.com/Art/SubjectList.asp?Inventory Wide
All of those "Claude Claude Claude Claude" words are urls that are:
file:///Z:/bench/Claude
Which is how I have this directory shared with windows, mounted as a
samba share as drive Z in Windows. Here is what needs improving and if
you want to lend a hand, of course I would honor your assistance, but it
will give me something to do in my spare time (If I ever get any), to
look up this scripting and figure it out.
This is what is great about it:
1.) Works great and fast.
2.) Nice colors in an html file with real html links.
3.) Totally clickable.
This is what is really, really wrong with it and makes it not useable:
1.) urls need to be one per line, list fashion, rather than one, huge
block of unbroken text. A carraige return needs to be inserted after each
url to drop down to next line.
2.) It is not necessary or desirable to include the pwd in the html file.
3.) This really makes no sense, I see the word "Raton" as in Boca Raton
repeated over and over, each one is a url to file:///Z:/bench/Raton
4.) There are many, many baseurl links that are useless, for example:
design.url:BASEURL
5.) This is a *way* cool idea but I think the problem is that you have no
desktop shortcuts to practice your script on, and I am quite sure that
your code is based on sound principals. To make this easier if you would
like to try out your own script, I have provided a zip file of all of the
desktop shortcuts for you to experiment with or at least try the script
with. Here you go:
http://www.ohmster.com/~ohmster/temp/desktopshortcuts.zip
Thank you Bit Twister. I sure would love to see this script rise to
fruition, but for now, John's quick text links will have to do until I
can get a better, working html generator script in place.
Thanks for the time and the lesson!
> The " was to be escaped. :)
>
> Saw the other post about category 3. Here try this one.
>
I will try it now Bit, but there were some very serious errors in the
script and I provided a url to a zip file of all the shortcut files for you
to practice on if you want. The thing has problems, maybe this one will be
better and leave out all of the useless basurl links and repetitive words
and useless links that go nowhere.
> The " was to be escaped. :)
>
> Saw the other post about category 3. Here try this one.
No good. This is no way useable or good. It is because you have no files
to test it on I am sure. Here are the desktop shortcut files that I am
working with:
http://www.ohmster.com/~ohmster/temp/desktopshortcuts.zip
Grab that zip file, unzip it to an empty test directory, and run your
script on it, watch what happens. Not what you thought, eh? Me either.
This needs fixing, BAD!
Here is a section of John's output text file:
http://www.absolutearts.com/
http://www.artcalendar.com/home.asp
http://www.jeanclaudearts.com/index.html
http://www.absolutearts.com/jboutrouil/
http://www.artnet.com/
http://www.artspan.com/
http://www.janeris.com/
Nice. Sweet. Other than missing out on the "=3" part of the url, this is
very good.
Here is a section of your urls.txt:
AbsoluteArts.com.url:BASEURL=http://www.absolutearts.com/
Art Calendar.url:BASEURL=http://www.artcalendar.com/home.asp
Art-Jean Claude Arts.url:BASEURL=http://www.jeanclaudearts.com/index.html
ArtJean Claude Boutrouille
-.url:BASEURL=http://www.absolutearts.com/jboutrouil/
ArtJean Claude Boutrouille
-.url:BASEURL=http://www.absolutearts.com/login4favorites.html
ArtJean Claude Boutrouille -.url:BASEURL=about:blank
ArtJean Claude Boutrouille -.url:BASEURL=about:blank
Artnet -.url:BASEURL=http://www.artnet.com/
Artnet -.url:BASEURL=http://trk.roitrax.com/artnet/rts.html?tver=4&cid=
3070&rts_id=291&cf=source&ccf=ccat&dh=www.artnet.com&dp=/
&ds=&dr=&rp=http&af=afid&kf=kfid&lf=lfid
What in the hell is that? Why all of the repetition?
Here is a section of your url.html file:
/home/ohmster/bench http://www.absolutearts.com/ Calendar.url:BASEURL
http://www.artcalendar.com/home.asp Claude Arts.url:BASEURL
http://www.jeanclaudearts.com/index.html Claude Boutrouille -.url:BASEURL
http://www.absolutearts.com/jboutrouil/ Claude Boutrouille -.url:BASEURL
http://www.absolutearts.com/login4favorites.html Claude Boutrouille
-.url:BASEURL about:blank Claude Boutrouille -.url:BASEURL about:blank
-.url:BASEURL http://www.artnet.com/ -.url:BASEURL
http://trk.roitrax.com/artnet/rts.html?tver 4&cid 3070&rts_id 291&cf
source&ccf ccat&dh www.artnet.com&dp /&ds &dr &rp http&af afid&kf kfid&lf
lfid -.url:BASEURL http://trk.roitrax.com/artnet/rts.html?tver 4&cid 3070
&rts_id 291&cf source&ccf ccat&dh www.artnet.com&dp /&ds &dr &rp http&af
All of it runs together, there is no line drop to next line for each
separate url, many urls go nowhere such as "file:///Z:/bench/Claude%
20Boutrouille%20-.url:BASEURL%
20http://www.absolutearts.com/login4favorites.html" Heh, not a very
useful url to say the least. The underlines in the urls form one
continuous line so that I have no idea where one url ends and another
begins. Plus, many of them are senseless. What can you do with a url like
this one? "dickson.url:BASEURL%
20http://www.markdicksonstudios.com/Artiststatement.html"
Too late for me now, have to go sleep for work early tomorrow. Play with
the zip file url files and see for yourself what happens. I am sure that
once you have the url files on your drive, all you need do is tweak one
or two items and the output would be nice. Thank you Bit Twister, for
taking the time and for helping me get an education.
I will check back tomorrow, goodnight!
Then you change html controls to use list instead of what I picked.
> 2.) It is not necessary or desirable to include the pwd in the html file.
Hey, it is your code on your system, you take it out. :-)
> 3.) This really makes no sense, I see the word "Raton" as in Boca Raton
> repeated over and over, each one is a url to file:///Z:/bench/Raton
Unless I can see the file, I can not see the fix.
> 4.) There are many, many baseurl links that are useless, for example:
> design.url:BASEURL
Need to see the shortcut file.
> 5.) This is a *way* cool idea but I think the problem is that you have no
> desktop shortcuts to practice your script on, and I am quite sure that
> your code is based on sound principals. To make this easier if you would
> like to try out your own script, I have provided a zip file of all of the
> desktop shortcuts for you to experiment with or at least try the script
> with. Here you go:
> http://www.ohmster.com/~ohmster/temp/desktopshortcuts.zip
Ok, try this one
#!/bin/bash
_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
<ul>
" > $_out_fn
grep --no-filename BASEURL= *.url > urls.txt
while read -r _line ; do
set -- $(IFS='=' ; echo $_line)
shift
echo "<li><A href=\"$*\">$*</A>" >> $_out_fn
done < urls.txt
echo "
</li>
</ul>
>> This is what is really, really wrong with it and makes it not
>> useable: 1.) urls need to be one per line, list fashion, rather than
>> one, huge block of unbroken text. A carraige return needs to be
>> inserted after each url to drop down to next line.
>
> Then you change html controls to use list instead of what I picked.
Oh Bit, please do not get mad at me, this is not critisism or non-
appreciation. I do appreciate the script and the education very, very
much. :)
>> 2.) It is not necessary or desirable to include the pwd in the html
>> file.
>
> Hey, it is your code on your system, you take it out. :-)
Of course.
>> 3.) This really makes no sense, I see the word "Raton" as in Boca
>> Raton repeated over and over, each one is a url to
>> file:///Z:/bench/Raton
>
> Unless I can see the file, I can not see the fix.
I will supply all the files you need on my comcast personal web server
space if that will help. Will give the shortcuts, and the script and
output files for you to examime. Thanks!
>> 4.) There are many, many baseurl links that are useless, for example:
>> design.url:BASEURL
>
> Need to see the shortcut file.
They are coming!
>> 5.) This is a *way* cool idea but I think the problem is that you
>> have no desktop shortcuts to practice your script on, and I am quite
>> sure that your code is based on sound principals. To make this easier
>> if you would like to try out your own script, I have provided a zip
>> file of all of the desktop shortcuts for you to experiment with or at
>> least try the script with. Here you go:
>> http://www.ohmster.com/~ohmster/temp/desktopshortcuts.zip
>
> Ok, try this one
Sending what you need to see what needs to happen.
http://home.comcast.net/~theohmster/files/desktopshortcuts.zip
http://home.comcast.net/~theohmster/files/BT_Files.zip
Okay, there are the desktop shortcuts and there are the 3 Bit Twister
files. The one that contains the script, the text output, and the html
output. Help me please Bit Twister, you are so close man!
Thank you!
grep '^URL=http://' *.url | cut -f2- -d= > urls
The change is the addition of a dash after "-f2". It tells cut to print
the second field and all subsequent fields rather than only the second
field.
Hehehe, not getting mad. You have to decide to make the cosmetic changes.
>>
>> Need to see the shortcut file.
>
> They are coming!
> http://home.comcast.net/~theohmster/files/desktopshortcuts.zip
Got them
> Sending what you need to see what needs to happen.
> http://home.comcast.net/~theohmster/files/BT_Files.zip
No idea why I cannot unzip that one.
[bittwister@cooker zip]$ unzip BT_Files.zip
Archive: BT_Files.zip
skipping: urls.html `PPMd' method not supported
skipping: urls.txt `PPMd' method not supported
skipping: geturls `PPMd' method not supported
Does not matter. I can see the urls.html from last script I sent
using your zipped desktopshortcuts.zip
Lots of them work. Some you may have to tweak in the code.
You will need to provide broken url for me to look at. Latest copy of
code for us to work with.
#!/bin/bash
_out_fn=urls.html
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<!-- save as index.html -->
<!-- Enter file:$_out_fn in browser Location: -->
<HTML>
<HEAD>
<TITLE>Local Home Page $_out_fn </TITLE>
> This should work:
>
> grep '^URL=http://' *.url | cut -f2- -d= > urls
>
> The change is the addition of a dash after "-f2". It tells cut to print
> the second field and all subsequent fields rather than only the second
> field.
Wow, that really worked. I was afraid that I would have to use the first
output and redo it all over by hand because I don't know which urls are
good and which are not. But this second version really seemed to do the
trick, and on time too! I can now get this job done in a timely fashion,
thank you very much John.
I am so anxious to see what Bit Twister comes up with. He is working so
hard on an html version that would be really cool, but it has too many bugs
in it as of right now. I cannot say I blame him, he has nothing to work
with so maybe once he gets a chance to see the url files that I have to
work with, his script may be salvageable. I hope so, it sure does look
promising, plus he did a great job on commenting it too so that I can learn
from it. But I will hand it to you John, you got the job done as a text
file and I can work with that. Thanks and goodnight.
Here is the script using John's grep command.
#!/bin/bash
_out_fn=urls.html
_in_fn=urls.txt
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<!-- save as index.html -->
<!-- Enter file:$_out_fn in browser Location: -->
<HTML>
<HEAD>
<TITLE>Local Home Page $_out_fn </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\">
<ul>
" > $_out_fn
grep --no-filename '^URL=http://' *.url | cut -f2- -d= > $_in_fn
while read -r _line ; do
echo "<li><A href=\"$_line\">$_line</A>" >> $_out_fn
done < $_in_fn
> No idea why I cannot unzip that one.
> [bittwister@cooker zip]$ unzip BT_Files.zip
> Archive: BT_Files.zip
> skipping: urls.html `PPMd' method not supported
> skipping: urls.txt `PPMd' method not supported
> skipping: geturls `PPMd' method not supported
>
> Does not matter. I can see the urls.html from last script I sent
> using your zipped desktopshortcuts.zip
You could not unzip it because I used winzip to make that one file and it
came out with an x at the end as in BT_Files.zipx. I thought nothing of it
and deleted the x. Apparently there was more to it than that. I have now
rezipped the same files in Linux and upped it to the server, you can
retrieve the BT_Files.zip now and you will be able to unzip it. Sorry.
http://home.comcast.net/~theohmster/files/BT_Files.zip
It is very late for me but I will test your new script, thank you BT.
Ok, zip contents of geturls was a few changes out of date. :(
Once you start running latest one. You should be fairly close to
having something you can really play around with.
> Lots of them work. Some you may have to tweak in the code.
> You will need to provide broken url for me to look at. Latest copy of
> code for us to work with.
>
Holy shit, you fixed the crap out of this one! This is great!!!
Oh I can sooooooo use this. One thing I really have to do is to make
these links have a blank target attribute set so that they open in a new
window or tab. I was going to use a macro to add that to all urls in a
text editor but if it can be done on the fly in your script, man that
would be the cat's PJs man! And make the output justify left, not center.
The below urls are all on one line but for line wrapping in the
newsreader program.
Example of URL without the target attribute set (Plain URL):
<a href="http://www.artinthepicture.com/artists/Nicolas_de_Stael/">
http://www.artinthepicture.com/artists/Nicolas_de_Stael/</a
Example of URL with target attribute set:
<a href="http://www.artinthepicture.com/artists/Nicolas_de_Stael/"
target="_blank">http://www.artinthepicture.com/artists/Nicolas_de_Stael/
</a
See how the bottom url has that target stuff in it? If you click a url
like that, it will open in a new tab or window and the visitor will not
leave the referring website by clicking the link. That is the kind of
links that I have to make. I may be able to use "Find and replace" in a
text editor to do this, or a macro maybe. The idea is to automate this
and not have to do every link by hand, this guy gives me tons of links at
times and this is a tool that I really need. This script is really good
so far though, you fixed almost everything that was wrong with it. Okay,
I will try your "John version" now and see how that one works. Thanks BT!
>
> Here is the script using John's grep command.
This works really good BT, same as your last one. Now if you could only get
the target attribute in the script, man oh man, what a treasure that would
be!!
Thanks Bit Twister!
Just remember when playing in the echo "some text string(s)"
that if you enter something like target="_blank">
you need to escape any quotes you add. Example target=\"_blank\">
> would be the cat's PJs man! And make the output justify left, not center.
Remove CENTER keywords. :)
> Example of URL without the target attribute set (Plain URL):
><a href="http://www.artinthepicture.com/artists/Nicolas_de_Stael/">
> http://www.artinthepicture.com/artists/Nicolas_de_Stael/</a
>
> Example of URL with target attribute set:
><a href="http://www.artinthepicture.com/artists/Nicolas_de_Stael/"
> target="_blank">http://www.artinthepicture.com/artists/Nicolas_de_Stael/
></a
>
> See how the bottom url has that target stuff in it? If you click a url
> like that, it will open in a new tab or window and the visitor will not
> leave the referring website by clicking the link. That is the kind of
> links that I have to make.
Looking at John's version of my script the line would look something
like
echo "<li><A href=\"$_line target=\"_blank\">$_line</A>" >> $_out_fn
> This works really good BT, same as your last one. Now if you could only get
> the target attribute in the script, man oh man, what a treasure that would
> be!!
Bitch, bitch, bitch..... :-D
#!/bin/bash
_out_fn=urls.html
_in_fn=urls.txt
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<!-- save as index.html -->
<!-- Enter file:$_out_fn in browser Location: -->
<HTML>
<HEAD>
<TITLE>Local Home Page $_out_fn </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
<ul>
" > $_out_fn
grep --no-filename '^URL=http://' *.url | cut -f2- -d= > $_in_fn
while read -r _line ; do
echo "<li><A href=\"$_line\" target=\"_blank\">$_line</A>" >> $_out_fn
The </li> is in the wrong place :-(
#!/bin/bash
_out_fn=urls.html
_in_fn=urls.txt
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<!-- save as index.html -->
<!-- Enter file:$_out_fn in browser Location: -->
<HTML>
<HEAD>
<TITLE>Local Home Page $_out_fn </TITLE>
<TR>
<!-- Background wheat, links blue (unvisited), navy (visited), red (active) -->
<BODY
BGCOLOR=\"Wheat\"
LINK=\"Blue\"
VLINK=\"Red\"
ALINK=\"Green\"
TEXT=\"Black\"
<ul>
" > $_out_fn
grep --no-filename '^URL=http://' *.url | cut -f2- -d= > $_in_fn
while read -r _line ; do
echo "<li><A href=\"$_line\" target=\"_blank\">$_line</A></li>" >> $_out_fn
done < $_in_fn
echo "
Yo Cousin Ohm ....
I'm still around and kickin' ....
Thanks for the kind words.
--
Stanley C. Kitching
Human Being
Phoenix, Arizona
> Looking at John's version of my script the line would look something
> like
>
> echo "<li><A href=\"$_line target=\"_blank\">$_line</A>" >> $_out_fn
>
Late for work, more tonight!
[ohmster@ohmster bench]$ echo "<li><A href=\"$_line target=\"_blank\">
$_line</A>" >> $_out_fn
-bash: $_out_fn: ambiguous redirect
[ohmster@ohmster bench]$
Not sure what the problem is, but whatever you wrote in the big script
looks promising, will test it out tonight. Thank you so much, Bit Twister!
>
> Yo Cousin Ohm ....
>
> I'm still around and kickin' ....
>
> Thanks for the kind words.
Cousin Stanley!!!! I still use ohms_work.py to this very day, it is a most
excellent work of art. Thank you my very, very good friend. ;>)
>> This works really good BT, same as your last one. Now if you could
>> only get the target attribute in the script, man oh man, what a
>> treasure that would be!!
>
> Bitch, bitch, bitch..... :-D
Thats it! Now I have all three methods tucked away in my scripts directory
where they can be used anywhere, anytime!
[ohmster@ohmster scripts]$ ls -la geturls*
-rwxrwxr-x 1 ohmster ohmster 705 2010-03-16 09:49 geturls-html
-rwxrwxr-x 1 ohmster ohmster 722 2010-03-16 09:45 geturls-target
-rwxr-xr-x 1 ohmster ohmster 59 2010-03-15 23:51 geturls-txt
[ohmster@ohmster scripts]$
As soon as I get some rest and stop this "dead man walking" stuff, I want
to study your stuff so I am saving this entire thread to help me in my
scripting studies. Thank you John and thank you Bit Twister, you guys got
the job done, in time, and gave me a valuable lesson and education in
scripting.
Gotta go to work now, late! But, had to give thanks where thanks is very
much due! Thnx!
Easiest is probably to copy those .url files into the favorites folder
of some user on windows, start internet explorer as that user and export
his favorites to a file (bookmarks.htm).
That way you'll end up with a html file with clickable links.
Beware of things like & and other encoding errors though.
Michel.
> Easiest is probably to copy those .url files into the favorites folder
> of some user on windows, start internet explorer as that user and
> export his favorites to a file (bookmarks.htm).
>
> That way you'll end up with a html file with clickable links.
>
> Beware of things like & and other encoding errors though.
>
> Michel.
...sigh. That's a pretty dammed good idea, Michel. I forgot that
Internet Explorer actually does work that way, all favorites are
actually stored as url files in a folder. I just checked on my Windows 7
machine and yes that is true. And yeah, I just opened up Internet
Explorer and checked File, Export, and you can indeed export all of
those url files as a single bookmarks.html file. Your idea would have
worked and would have worked just fine, but for the necessity to have
these links "Open in a new window or tab", i.e.:, the target attribute.
But yep, that is a dammed good idea and would have been the easiest way
out of this pinch. Thank you for bringing that to my attention. Now I
consider myself quite advanced with computers and this response has made
me feel utterly stupid for overlooking it. But hey, shit happens man,
thanks for the info!
Besides, I did have an *awful lot of fun* with Bit Twister and John and
the very creative Linux scripts and command tricks that they gave to me.
I positively love the rich scripting evnvironment that Linux offers. If
one is good at scripting, any kind, be it shell, python, perl, etc., you
can do almost any repetative task that would take forever by hand in
seconds with just the right combination of characters in a command line
or in a script. I have a scripts directory in my Home directory on Linux
and it is in my path, and I use it all the time for all kinds of neat
things that I need to do now and then. I have cron run scriptst that
check for any ftp uploads and then email me if it finds any new files, I
have a python script by cousin Stanley that takes my text FAQ and makes
a dammed good html document out of it with clickable links and named
anchors so now all I have to do is update the text copy of the FAQ and
Stanley's magnificent script does all the html work for me. Linux rules
and the scripting rocks. But, you get a BIG kudos for using common sense
and reminding me about IE's behavior and how to easily make an html file
out of those url files, right in Windows, without any fancy scripts or
tools.
Dam, I learn a LOT in here. That's why I love this newsgroup. Thanks
everybody! :) --
> 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.
It has been a while, I forgot to come back and say "Thanks Bit Twister!".
Oh yeah, you are the one with the wacky mouse-potato.com email address that
loops back to the sender. I swear I was thinking of you and that yesterday
and tried to google the mouse potato domain and go nowhwere with it. Glad I
found you again. Really thanks budness!