Export IE Favorites to Mozilla BookMark File Format (VBS)
Big thanks to disciple for the code to extract the url in Bash (I probably won't have done this otherwise).
http://www.murga-linux.com/puppy/viewtopic.php?t=12262
*this code writes a file 'bookmarks.html' to your root directory. If you are saving you bookmarks there, please back them up before running the script.
Run it like this to specify bookmark directory location:
#./ThisScript "/mnt/hda1/Documents and Settings/UserName/Favorites/"
or just run it and it will ask you where the favorites are.
The code:
Code: Select all
#!/bin/sh
#**************************************
# Name: IE Browser Favorites Export
# Description: Make a NETSCAPE-Bookmark-file-1 from IE Favorites
# By: John Doe
#
#This script is released for all Puppy Users to import IE Favorites
#**************************************
#
#These are normal:
#ls: */: No such file or directory
#means you have reached the end of a directory branch
#ls: *.url: No such file or directory
#means there where no url files in that directory
#other ls errors seemed to be caused by files having -- in the name and something else. I have 3 out of ~2000 die on the machine I'm on. Two for --'s and one for "something else" [maybe +].
function DoDirectory
{
cd "$1"
ls -d */ | while read name
do
echo "<DT><H3>${name%%/}</H3>" >> ~/bookmarks.html
# Write Folder Content Start Tag
echo "<DL><p>" >> ~/bookmarks.html
# RECURSE
DoDirectory "$1$name"
DoFiles "$1$name"
# Write Folder Content End Tag
echo "</DL><p>" >> ~/bookmarks.html
done
}
function DoFiles
{
cd "$1"
ls *.url | while read name
do
#Thanks to disciple for this code to extract the url
#http://www.murga-linux.com/puppy/viewtopic.php?t=12262
linebefore=`fgrep -in [InternetShortcut] "$name" | awk -F":" '{print $1}'`
line=`expr $linebefore + 1`
url=`tail +$line "$name" | head -n 1`
url=`echo ${url#URL=} | sed 's/[ \t\n\r]*$//'`
echo "<DT><A HREF=\"$url\">${name%.url}</A>" >> ~/bookmarks.html
done
}
function DoWork
{
#clear ~/bookmarks.html if it's there
echo "" > ~/bookmarks.html
# Write DOC TYPE
echo "<!DOCTYPE NETSCAPE-Bookmark-file-1>" >> ~/bookmarks.html
echo "<!-- This is an automatically generated file." >> ~/bookmarks.html
echo " It will be read and overwritten." >> ~/bookmarks.html
echo " DO NOT EDIT! -->" >> ~/bookmarks.html
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">" >> ~/bookmarks.html
echo "<TITLE>Bookmarks</TITLE>" >> ~/bookmarks.html
echo "<H1>Bookmarks</H1>" >> ~/bookmarks.html
# Write Folder Content Start Tag
echo "<DL><p>" >> ~/bookmarks.html
DoDirectory "$FavDir"
DoFiles "$FavDir"
# Write Folder Content End Tag
echo "</DL><p>" >> ~/bookmarks.html
}
#Usage:
#Optional arg to specify favorite location
#example:
#./ThisScript "/mnt/hda1/Documents and Settings/JohnDoe/Favorites/"
if [ "$1" != "" ]; then
FavDir="$1"
else
Xdialog --wrap --left --title "IE Favorite Wizard" \
--msgbox "This wizard will import your Microsoft Internet Explorer Favorite Directory\nto a Mozilla bookmark.html file.\n\nA file will be created at /root/bookmarks.html\n\nIf you have a file there, please back it up now." 0 0 >&1
if [ "$?" == "255" ]; then
echo "Export Canceled."
exit
fi
FavDir=`Xdialog --wrap --left --backtitle "Please choose the directory that contains your Microsoft Windows Internet Explorer Favorites..." --title "IE Favorite Wizard" --dselect /root 35 75 2>&1`
case $? in
0)
echo "\"$FavDir\" chosen";;
1)
echo "Export Canceled."
exit;;
255)
echo "Export Canceled."
exit;;
esac
fi
if [ "$FavDir" != "" ]; then
Xdialog --wrap --left --title "IE Favorite Wizard" \
--msgbox "The wizard will now run in the background (could take several minutes).\n\nPlease wait for a message before importing your bookmarks.html file into Mozilla." 0 0 >&1
if [ "$?" == "255" ]; then
echo "Export Canceled."
exit
fi
DoWork "$FavDir"
echo "Export Complete."
Xdialog --wrap --left --title "IE Favorite Wizard" \
--msgbox "Export Complete. Your bookmark.html file can now be imported into Mozilla.\n\n1-Launch Mozilla, go to \"Bookmarks->Manage Bookmarks...\"\n\n2-Go to \"Tools->Import...\"\n\n3-Select /root/bookmarks.html\n\n4-Click \"Open\"\n\n5-Finished" 0 0
case $? in
0)
echo "OK";;
255)
echo "Box closed.";;
esac
else
echo "Export Canceled."
Xdialog --wrap --left --title "IE Favorite Wizard" \
--msgbox "You have canceled the wizard." 10 41
case $? in
0)
echo "OK";;
255)
echo "Box closed.";;
esac
fi
Code: Select all
[Desktop Entry]
Encoding=UTF-8
Name=IE Favorite Wizard
Icon=wizard16.xpm
Comment=IE Favorite Wizard
Exec=iefavwizard
Terminal=false
Type=Application
Categories=X-SetupWizard
GenericName=IE Favorite Wizard