Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 20 Nov 2018, 01:26
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
Import IE Favorites to Mozilla BookMark File Format (BASH)
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [2 Posts]  
Author Message
John Doe

Joined: 01 Aug 2005
Posts: 1689
Location: Michigan, US

PostPosted: Thu 05 Apr 2007, 01:14    Post subject:  Import IE Favorites to Mozilla BookMark File Format (BASH)
Subject description: *Now with XDialog Directory Selection Support*
 

If you need to do this from inside Windows due to AD or other reason(s) see:
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:
#!/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


iefavwizard.desktop

Code:
[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
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6863
Location: Auckland, New Zealand

PostPosted: Fri 24 Aug 2018, 00:56    Post subject:  

Note that recent versions of Internet Explorer have both Favourites (stored somewhere like "C:\Users\your_name\Favorites") and "Pinned Sites" (stored somewhere like "C:\Users\your_name\AppData\Local\Microsoft\Internet Explorer\Pinned Sites").

The "Pinned Sites" are in newfangled "*.website" files. These look like a fairly simple extension of the old *.url files, and they are now the default if you drag and drop a page into windows explorer (you need to hold shift to get a *.url). The point in the new format is supposed to be to support things like jumplists and push notifications and favicons, although it seems to me that the latter were already supported.

I haven't tested (or looked back at any of the code), but tools like this for dealing with *.url files are likely to work for *.website files without modification.

_________________
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [2 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0488s ][ Queries: 12 (0.0079s) ][ GZIP on ]