Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2009-05-18
9
Medium Priority
?
316 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 600 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 1400 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

636 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