Import Favorites from IE
Import Favorites from IE
(OP)
I would like to import favorites from IE to a *.tps file.
I would normally use a *.csv file for this purpose but IE does not allow me to export my favorites to a *.csv file, only to a HTML file.
Is there any way I can import my favorites from IE to a *.tps file?
Thanks.
I would normally use a *.csv file for this purpose but IE does not allow me to export my favorites to a *.csv file, only to a HTML file.
Is there any way I can import my favorites from IE to a *.tps file?
Thanks.
RE: Import Favorites from IE
All Favorites are stored in the C:\Documents and Settings\<WindowsUserName>\Favorites folder on XP and C:\Users\<WindowsUserName>\Favorites on Win7. Just use DIRECTORY() and scan through the folder and all it's sub-folders and open the Internet Shortcut files as a ASCII file and get your information. An example shortcut file is shown below ::
CODE
URL=http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&plcid=&pver=6.1&os=&over=&olcid=&clcid=&ar=Media&sba=RadioBar&o1=&o2=&o3=
Modified=3078545FFF99C701BB
Regards
RE: Import Favorites from IE
The bit I do not understand is after using DIRECTORY() to locate the favorites folder how do I go about scanning the folder and its sub folders and return the shortcuts as a ACSII file?
RE: Import Favorites from IE
CODE
FullPath STRING(512)
END
FileQueue QUEUE(File:queue),PRE(FQ)
END
URLQueue QUEUE,PRE(URL)
Name STRING(256)
Link STRING(1024)
END
LOC:Path STRING(512)
LOC:Counter LONG
LOC:Inner LONG
LOC:ASCFileName STRING(512)
ASCFile FILE,DRIVER('ASCII'),PRE(ASC),NAME(LOC:ASCFileName)
Record RECORD
Data STRING(512)
. .
FREE(URLQueue)
DQ:FullPath = 'C:\Documents and Settings\<WindowsUserName>\Favorites\'
ADD(DirQueue)
LOC:Counter = 0
LOOP
LOC:Counter += 1
GET(DirQueue, LOC:Counter)
IF ERRORCODE() THEN BREAK.
LOC:Path = DQ:FullPath
FREE(FileQueue)
DIRECTORY(FileQueue, CLIP(LOC:Path) & '*.*', ff_:Normal+ff_:DIRECTORY)
LOC:Inner = 0
LOOP
LOC:Inner += 1
GET(FileQueue, LOC:Inner)
IF ERRORCODE() THEN BREAK.
IF BAND(FQ:Attrib,ff_:DIRECTORY) AND FQ:ShortName <> '..' AND FQ:ShortName <> '.'
DQ:FullPath = CLIP(LOC:Path) & CLIP(FQ:Name) & '\'
ADD(DirQueue)
ELSE
LOC:ASCFileName = CLIP(LOC:Path) & CLIP(FQ:Name)
CLOSE(ASCFile)
OPEN(ASCFile,40H)
IF ERRORCODE()
ELSE
SET(ASCFile)
LOOP
NEXT(ASCFile)
IF ERRORCODE() THEN BREAK.
IF SUB(ASC:Data,1,4) = 'URL='
CLEAR(URLQueue)
URL:Name = FQ:FileName
URL:Link = SUB(ASC:Data,5,LEN(CLIP(ASC:Data))-4)
ADD(URLQueue)
BREAK
END
END
CLOSE(ASCFile)
END
END
END
END
Make sure you add the ASCII driver to your project's Database drivers. You can scan through the URLQueue and copy it to a TPS file.
Regards
RE: Import Favorites from IE
Just as a point of interest though I have found that a simple batch file like the one below seems to work OK (did not fully test) but would I be right in saying that its not a good practice to run a batch file(s) from an app?
cd \
cd MyFavoritesFolder
copy *.url url.txt
Kind Regards.
RE: Import Favorites from IE
Are you sure that "copy *.url url.txt" will copy all the URLs into one file? You could use "for %f in (*.url) do type %f >> url.txt" instead.
Running a batch file is not an issue but IMHO a liability as the application depends on something outside it.
Regards
RE: Import Favorites from IE
Yes, sorry my mistake, the batch file example I posted will not copy all the files. Having thought about it a bit more I would not use a batch file as I am not comfortable in doing so but I thought it was still worth a mention as an easy way for anyone wanting to export their own favorites to text.
Thanks again for all your help.