Change text strings (links) in jsp files.

We have a windows based web server.

We have a folder of jsp files (java/html) that have links in them pointing to web pages in our subdomain. The admin would like to change the subdomain name.

I am looking for an easy way to change the subdomain text string in all of the files in the folder.

For example, change all occurrences of:
<a href="" ></a>

<a href="" ></a>


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Muhammad KhanManager, ITCommented:
does it have to be DOS? i wrote a simple vbscript for you.. just save it as a vbs file in the same folder as of your jsp's and run it... make sure you first take backup of your jsp files...

dim fso
dim tStream
dim tFolder 
dim tFile
dim tString
set fso = createobject("Scripting.FileSystemObject")
set tFolder = fso.getFolder (".")
for each tFile in tFolder.Files
if ucase(right(,3))="TXT" then 
	set tstream=fso.opentextfile(tFile.path,1)
        tString =tStream.readAll
	set tstream=fso.opentextfile(tFile.path,2)
msgbox tstring
	tstream.write replace(tString,"<a href="""" ></a>","<a href="""" ></a>")
end if

Open in new window

mph23Author Commented:
What extension would I use to save the vbscript?
Do I need any microsoft products installed to run it?

Muhammad KhanManager, ITCommented:
its extension should be VBS... and one more point to note... in above code at line 9. you need to replace TXT with JSP.
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Why not just using a text editor like Notepadd++ (free). Use the search and replace in files feature and your done.
Bill PrewCommented:
Grab the CHGSTR util from the link below and use it.  Help can be displayed via CHGSTR /?

A GUI based tool that might suit your needs and is also free:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mph23Author Commented:
vkphoenixfr - there are so many files, it'll take too long.
chgstr.exe will do this in multiple files, and it traverses sub-folders.  For example:

  chgstr  "searchstring"  "replacestring"  *.jsp  /s
Bill PrewCommented:
Agreed, both CHGSTR and WINGREP can recurse into subfolders and process just selected extensions.  Simple, and fast.

mph23Author Commented:
Thanks for your help.

FYI - wingrep is $30.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.