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?
Bill PrewConnect With a Mentor Commented:
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:

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?

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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.
Why not just using a text editor like Notepadd++ (free). Use the search and replace in files feature and your done.
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.