Solved

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

Posted on 2009-05-18
9
308 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
 
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

929 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

16 Experts available now in Live!

Get 1:1 Help Now