Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - batch replace href value

Reply
 
Old 09-09-2009   #1 (permalink)
buddy


 
 

batch replace href value

I've got a big html page.Now I want to batch replace href value of it.
The file as follow:

<TR>
<TD vAlign=center align=middle bgColor=#ffffff height=25><A
href=" 0793.asp?id=86" target=_blank>######</A></TD>
<TD vAlign=center align=middle bgColor=#ffffff><FONT
color=#ff0000>####</FONT></TD>
<TD vAlign=center align=middle
bgColor=#ffffff>http://www.******.com/</TD></TR>
<TR>
<TR>
<TD vAlign=center align=middle bgColor=#ffffff height=25><A
href=" 0794.asp?id=87" target=_blank>######</A></TD>
<TD vAlign=center align=middle bgColor=#ffffff><FONT
color=#ff0000>#####</FONT></TD>
<TD vAlign=center align=middle
bgColor=#ffffff>http://www.xxxxx.com/</TD></TR>
<TR>

I want to replace the value like this:

0793.asp?id=86 ---- http://www.******.com/
0794.asp?id=87 ---- http://www.xxxxx.com/

The e.g is just part of the page, the hrefs and urls is different. If
I use copy and paste it'll be a hard task.Could sombody help me please?

My System SpecsSystem Spec
Old 09-09-2009   #2 (permalink)
Pegasus [MVP]


 
 

Re: batch replace href value


"buddy" <buddy.qin@xxxxxx> wrote in message
news:db126f5b-3c60-4077-80b2-e0777112bb91@xxxxxx
Quote:

> I've got a big html page.Now I want to batch replace href value of it.
> The file as follow:
>
> <TR>
> <TD vAlign=center align=middle bgColor=#ffffff height=25><A
> href=" 0793.asp?id=86" target=_blank>######</A></TD>
> <TD vAlign=center align=middle bgColor=#ffffff><FONT
> color=#ff0000>####</FONT></TD>
> <TD vAlign=center align=middle
> bgColor=#ffffff>http://www.******.com/</TD></TR>
> <TR>
> <TR>
> <TD vAlign=center align=middle bgColor=#ffffff height=25><A
> href=" 0794.asp?id=87" target=_blank>######</A></TD>
> <TD vAlign=center align=middle bgColor=#ffffff><FONT
> color=#ff0000>#####</FONT></TD>
> <TD vAlign=center align=middle
> bgColor=#ffffff>http://www.xxxxx.com/</TD></TR>
> <TR>
>
> I want to replace the value like this:
>
> 0793.asp?id=86 ---- http://www.******.com/
> 0794.asp?id=87 ---- http://www.xxxxx.com/
>
> The e.g is just part of the page, the hrefs and urls is different. If
> I use copy and paste it'll be a hard task.Could sombody help me please?
For a single file the most efficient solution would be to use notepad.exe.


My System SpecsSystem Spec
Old 09-09-2009   #3 (permalink)
buddy


 
 

Re: batch replace href value

On Sep 9, 9:18*pm, "Pegasus [MVP]" <n...@xxxxxx> wrote:
Quote:

> "buddy" <buddy....@xxxxxx> wrote in message
>
> news:db126f5b-3c60-4077-80b2-e0777112bb91@xxxxxx
>
>
>
Quote:

> > I've got a big html page.Now I want to batch replace href value of it.
> > The file as follow:
>
Quote:

> > <TR>
> > * *<TD vAlign=center align=middle bgColor=#ffffff height=25><A
> > * * *href=" 0793.asp?id=86" target=_blank>######</A></TD>
> > * *<TD vAlign=center align=middle bgColor=#ffffff><FONT
> > * * *color=#ff0000>####</FONT></TD>
> > * *<TD vAlign=center align=middle
> > bgColor=#ffffff>http://www.******.com/</TD></TR>
> > <TR>
> > <TR>
> > * *<TD vAlign=center align=middle bgColor=#ffffff height=25><A
> > * * *href=" 0794.asp?id=87" target=_blank>######</A></TD>
> > * *<TD vAlign=center align=middle bgColor=#ffffff><FONT
> > * * *color=#ff0000>#####</FONT></TD>
> > * *<TD vAlign=center align=middle
> > bgColor=#ffffff>http://www.xxxxx.com/</TD></TR>
> > <TR>
>
Quote:

> > I want to replace the value like this:
>
Quote:

> > 0793.asp?id=86 *---- *http://www.******.com/
> > 0794.asp?id=87 *---- *http://www.xxxxx.com/
>
Quote:

> > The e.g is just part of the page, the hrefs and urls is different. If
> > I use copy and paste it'll be a hard task.Could sombody help me please?
>
> For a single file the most efficient solution would be to use notepad.exe..
Thanks Pegasus!But there's over 1000 urls must be replaced, if using
notepad.exe will be slowly.
My System SpecsSystem Spec
Old 09-09-2009   #4 (permalink)
billious


 
 

Re: batch replace href value

buddy wrote:
Quote:

> On Sep 9, 9:18 pm, "Pegasus [MVP]" <n...@xxxxxx> wrote:
Quote:

>> "buddy" <buddy....@xxxxxx> wrote in message
>>
>> news:db126f5b-3c60-4077-80b2-e0777112bb91@xxxxxx
>>
>>
>>
Quote:

>>> I've got a big html page.Now I want to batch replace href value of
>>> it. The file as follow:
>>
Quote:

>>> <TR>
>>> <TD vAlign=center align=middle bgColor=#ffffff height=25><A
>>> href=" 0793.asp?id=86" target=_blank>######</A></TD>
>>> <TD vAlign=center align=middle bgColor=#ffffff><FONT
>>> color=#ff0000>####</FONT></TD>
>>> <TD vAlign=center align=middle
>>> bgColor=#ffffff>http://www.******.com/</TD></TR>
>>> <TR>
>>> <TR>
>>> <TD vAlign=center align=middle bgColor=#ffffff height=25><A
>>> href=" 0794.asp?id=87" target=_blank>######</A></TD>
>>> <TD vAlign=center align=middle bgColor=#ffffff><FONT
>>> color=#ff0000>#####</FONT></TD>
>>> <TD vAlign=center align=middle
>>> bgColor=#ffffff>http://www.xxxxx.com/</TD></TR>
>>> <TR>
>>
Quote:

>>> I want to replace the value like this:
>>
Quote:

>>> 0793.asp?id=86 ---- http://www.******.com/
>>> 0794.asp?id=87 ---- http://www.xxxxx.com/
>>
Quote:

>>> The e.g is just part of the page, the hrefs and urls is different.
>>> If I use copy and paste it'll be a hard task.Could sombody help me
>>> please?
>>
>> For a single file the most efficient solution would be to use
>> notepad.exe.
>
> Thanks Pegasus!But there's over 1000 urls must be replaced, if using
> notepad.exe will be slowly.
Since you want to do a BATCH replace, why not try a BATCH group like
alt.msdos.batch.nt ?

Your query is far too vague.

If, for instance, you wish to replace
" 0793.asp?id=86"
with
http://www.sevenninethree.com

then executing from the prompt

for %i in (*.html) do sed -frepl.txt <%i >%i.rep

Where:

+ your source files are *.html
+ SED is the well-known SED utility (I use HHSED - google is your friend
(g)awk is a utility with similar functionality, preferred by some)
+ *.rep will be generated
+ the replacements are read from a file repl.txt, which is formatted as
lines like

s#\x22\x200793.asp?id=86\x22#\x22http://www.sevenninethree.com\x22#

Which reads "substitute for the first string between '#' with the second
string" and \xnn means 'hex-nn' to replace certain characters that may have
meaning to the utility in question. I used '#', but any character could be
used provided it does not appear in the target or substitute string. (all
this would be in the SED (etc) documentation)




s#\x22\x200793.asp?id=86\x22#\x22http://www.sevenninethree.com\x22#



My System SpecsSystem Spec
Old 09-09-2009   #5 (permalink)
Todd Vargo


 
 

Re: batch replace href value

buddy wrote:
Quote:

> On Sep 9, 9:18 pm, "Pegasus [MVP]" <n...@xxxxxx> wrote:
Quote:

>> "buddy" <buddy....@xxxxxx> wrote:
>>
Quote:

>>> I've got a big html page.Now I want to batch replace href value of
>>> it. The file as follow:
>>
Quote:

>>> <TR>
>>> <TD vAlign=center align=middle bgColor=#ffffff height=25><A
>>> href=" 0793.asp?id=86" target=_blank>######</A></TD>
>>> <TD vAlign=center align=middle bgColor=#ffffff><FONT
>>> color=#ff0000>####</FONT></TD>
>>> <TD vAlign=center align=middle
>>> bgColor=#ffffff>http://www.******.com/</TD></TR>
>>> <TR>
>>> <TR>
>>> <TD vAlign=center align=middle bgColor=#ffffff height=25><A
>>> href=" 0794.asp?id=87" target=_blank>######</A></TD>
>>> <TD vAlign=center align=middle bgColor=#ffffff><FONT
>>> color=#ff0000>#####</FONT></TD>
>>> <TD vAlign=center align=middle
>>> bgColor=#ffffff>http://www.xxxxx.com/</TD></TR>
>>> <TR>
>>
Quote:

>>> I want to replace the value like this:
>>
Quote:

>>> 0793.asp?id=86 ---- http://www.******.com/
>>> 0794.asp?id=87 ---- http://www.xxxxx.com/
>>
Quote:

>>> The e.g is just part of the page, the hrefs and urls is different.
>>> If I use copy and paste it'll be a hard task.Could sombody help me
>>> please?
>>
>> For a single file the most efficient solution would be to use
>> notepad.exe.
>
> Thanks Pegasus!But there's over 1000 urls must be replaced, if using
> notepad.exe will be slowly.
You should be able to complete the task manually in about an hour or so
while waiting for replys. <shrug>

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

My System SpecsSystem Spec
Old 09-10-2009   #6 (permalink)
Pegasus [MVP]


 
 

Re: batch replace href value


"buddy" <buddy.qin@xxxxxx> wrote in message
news:56db2f5b-55f1-4c8c-83b2-7f8f7b502466@xxxxxx
On Sep 9, 9:18 pm, "Pegasus [MVP]" <n...@xxxxxx> wrote:
Quote:

> "buddy" <buddy....@xxxxxx> wrote in message
>
> news:db126f5b-3c60-4077-80b2-e0777112bb91@xxxxxx
>
>
>
Quote:

> > I've got a big html page.Now I want to batch replace href value of it.
> > The file as follow:
>
Quote:

> > <TR>
> > <TD vAlign=center align=middle bgColor=#ffffff height=25><A
> > href=" 0793.asp?id=86" target=_blank>######</A></TD>
> > <TD vAlign=center align=middle bgColor=#ffffff><FONT
> > color=#ff0000>####</FONT></TD>
> > <TD vAlign=center align=middle
> > bgColor=#ffffff>http://www.******.com/</TD></TR>
> > <TR>
> > <TR>
> > <TD vAlign=center align=middle bgColor=#ffffff height=25><A
> > href=" 0794.asp?id=87" target=_blank>######</A></TD>
> > <TD vAlign=center align=middle bgColor=#ffffff><FONT
> > color=#ff0000>#####</FONT></TD>
> > <TD vAlign=center align=middle
> > bgColor=#ffffff>http://www.xxxxx.com/</TD></TR>
> > <TR>
>
Quote:

> > I want to replace the value like this:
>
Quote:

> > 0793.asp?id=86 ---- http://www.******.com/
> > 0794.asp?id=87 ---- http://www.xxxxx.com/
>
Quote:

> > The e.g is just part of the page, the hrefs and urls is different. If
> > I use copy and paste it'll be a hard task.Could sombody help me please?
>
> For a single file the most efficient solution would be to use notepad.exe.
Thanks Pegasus!But there's over 1000 urls must be replaced, if using
notepad.exe will be slowly.

==============

Have a cup of coffee while notepad performs the job!


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
batch replace href value VB Script
batch file / script to replace information VB Script
Fetch special characters like "Ñ" and absolute URL from href attribute of anchors VB Script
find all href attributes PowerShell
href Links & Junk Mail Vista mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46