Solved

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

Posted on 2009-05-18
9
307 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

760 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

19 Experts available now in Live!

Get 1:1 Help Now