Solved

Add each and every web address in a txt file to the Ie favorites.

Posted on 2009-05-18
9
309 Views
Last Modified: 2012-05-07
Hi,

Add each and every web address in a txt file to the Ie favorites.
i have these in a txt file
www.google.com
www.yahoo.com

Can anyone help me with a script that can add all into the favorites in my ie.

Regards
Sharath
0
Comment
Question by:bsharath
  • 6
  • 2
9 Comments
 
LVL 16

Expert Comment

by:t0t0
ID: 24415205
I can only offer you limited knowledge on this subject have spent only a few moments musing over this question and tinkering with URL files.

You need two pieces of information to create each favorites link:

   1) the name of the link
   2) the URL of the web page


STEP 1 - Create a text file (URL.TXT) containing a comma-delimited list such as:

   My Google,http://www.google.com
   My Yahoo,http://www.yahoo.com


STEP 2 - Copy the code below into notepad and save as MKURL.BAT

   @echo off
   set destination=%userprofile%\favorites
   for /f "tokens=1,* delims=," %%a in (url.txt) do (
      if not exist "%destination%\%%a.url" (
          >"%destination%\%%~a.url" echo [DEFAULT]
         >>"%destination%\%%~a.url" echo BASEURL=%%~b
         >>"%destination%\%%~a.url" echo [InternetShortcut]
         >>"%destination%\%%~a.url" echo URL=%%~b
         >>"%destination%\%%~a.url" echo IDList=
         >>"%destination%\%%~a.url" echo IconFile=
         >>"%destination%\%%~a.url" echo IconIndex=1
         >>"%destination%\%%~a.url" echo [{000214A0-0000-0000-C000-000000000046}]
         >>"%destination%\%%~a.url" echo Prop3=19,2
      )
   )


STEP 3 - Ensure both files are in the same directory then run the batch file: MKURL


This will create two files in:

   C:\Documents and Settings\...\Favorites\

in the current user's profile named:

   My Google.url
   My Yahoo.url


STEP 4 - Fire up Internet Explorer and check out the favorites.


This should get you on your way.....
0
 
LVL 7

Assisted Solution

by:Hubasan
Hubasan earned 150 total points
ID: 24415291
Here is the script that should create the favorites based on websites you have in your text file.

Just put your text file that contains all the websites in the same folder where you put the script and call that file Websites.txt, or chage the variable sSource to what ever your file is called.


'Define constants
Const ADMINISTRATIVE_TOOLS = 6
Const For_Reading = 1
Const cTitle = "Add Websites to Favorites"
 
'Create Shell, Network and FileSystem Objects
Set oShell = CreateObject("Shell.Application")
Set oFolder = oShell.Namespace(ADMINISTRATIVE_TOOLS)
Set oFolderItem = oFolder.Self
 
Set oWS = CreateObject("wscript.shell")
Set oFS = CreateObject("scripting.FileSystemObject")
 
sSource = "Websites.txt"
 
sScriptName = WScript.ScriptName
sScriptPath = WScript.ScriptFullName
 
sDestFld = oFolderItem.Path
 
'Setup Input File
sInputFile = Replace(sScriptPath, sScriptName, sSource)
Set oInputFile = oFS.OpenTextFile(sInputFile,For_Reading)
 
Do Until oInputFile.AtEndOfStream
	sWebsite = Empty
	aWebsite = Empty
	sname = Empty
	sWebSite = oInputFile.ReadLine
	aWebSite = Split(sWebSite, ".")
	sName = aWebSite(1) & ".url"
	Set oURLShortcut = oWS.CreateShortcut(sDestFld & "\" & sName)
	oURLShortcut.TargetPath = sWebSite
	oURLShortcut.Save	
Loop

Open in new window

0
 
LVL 7

Expert Comment

by:Hubasan
ID: 24415366
oh sorry t0t0. I wasn't aware you are helping this user already. I should really refresh the screen before posting. :-)

Well in any case bsharath if you want an alternative, my script is VBS and instructions are above.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 16

Expert Comment

by:t0t0
ID: 24416735
Hubasan...

It's not a problem.... we're working from two different approaches... it'll be interesting to see which method (if not both) the asker chooses....

 
0
 
LVL 16

Expert Comment

by:t0t0
ID: 24417011
If you want to work with your original list of URLs such as:

   www.google.com
   www.yahoo.com

then save your list as URL.TXT and run the modified batch file.

   @echo off
   set destination=%userprofile%\favorites
   for /f "tokens=*" %%a in (url.txt) do (
      for /f "tokens=2 delims=." %%b in ("%%a") do (
         if not exist "%destination%\%%b.url" (
            echo [DEFAULT]
            echo BASEURL=http://%%a
            echo [InternetShortcut]
            echo URL=http://%%a
            echo IDList=
            echo IconFile=
            echo IconIndex=1
            echo [{000214A0-0000-0000-C000-000000000046}]
            echo Prop3=19,2
         )>"%destination%\%%b.url"
      )
   )


NOTE: This will create two entries in your favorites menu:

   Yahoo
   Google

by creating the following two files in your 'favorites' folder:

   Yahoo.url
   Google.url

If you want to change these entries to something like "My Yahoo" and My Google" then you need to change the following two lines:

   if not exist "%destination%\%%a.url" (

   )>"%destination%\%%b.url"

to:

   if not exist "%destination%\My %%a.url" (

   )>"%destination%\My %%b.url"

(see where I slipped the 'My ' into those lines? You can customise this if you want to)
0
 
LVL 16

Expert Comment

by:t0t0
ID: 24417048
Sorry! Re-submitted due to typo....

If you want to work with your original list of URLs such as:

   www.google.com
   www.yahoo.com

then save your list as URL.TXT and run the modified batch file.

   @echo off
   set destination=%userprofile%\favorites
   for /f "tokens=*" %%a in (url.txt) do (
      for /f "tokens=2 delims=." %%b in ("%%a") do (
         if not exist "%destination%\%%b.url" (
            echo [DEFAULT]
            echo BASEURL=http://%%a
            echo [InternetShortcut]
            echo URL=http://%%a
            echo IDList=
            echo IconFile=
            echo IconIndex=1
            echo [{000214A0-0000-0000-C000-000000000046}]
            echo Prop3=19,2
         )>"%destination%\%%b.url"
      )
   )


NOTE: This will create two entries in your favorites menu:

   Yahoo
   Google

by creating the following two files in your 'favorites' folder:

   Yahoo.url
   Google.url

If you want to change these entries to something like "My Yahoo" and My Google" then you need to change the following two lines:

   if not exist "%destination%\%%b.url" (

   )>"%destination%\%%b.url"

to:

   if not exist "%destination%\My %%b.url" (

   )>"%destination%\My %%b.url"

(see where I slipped the 'My ' into those lines? You can customise this if you want to)
0
 
LVL 16

Accepted Solution

by:
t0t0 earned 350 total points
ID: 24417086
Sorry to bombard you with possible solutions hwever, i've trimmed this down some more. (to be used with your original list of URLs saved as URL.TXT).

   @echo off
   set destination=%userprofile%\favorites
   for /f "tokens=*" %%a in (url.txt) do (
      for /f "tokens=2 delims=." %%b in ("%%a") do (
         if not exist "%destination%\%%b.url" (
            echo [DEFAULT]
            echo BASEURL=http://%%a
            echo [InternetShortcut]
            echo URL=http://%%a
         )>"%destination%\%%b.url"
      )
   )

0
 
LVL 11

Author Comment

by:bsharath
ID: 24432930
Thank U
0
 
LVL 16

Expert Comment

by:t0t0
ID: 24433161
Thank you....
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now