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="http://old.mydomain.com/index.html" ></a>

to
<a href="http://www.mydomain.com/index.html" ></a>

Thanks!

 
mph23Asked:
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(tFile.name,3))="TXT" then 
	set tstream=fso.opentextfile(tFile.path,1)
        tString =tStream.readAll
	tStream.close
	set tstream=fso.opentextfile(tFile.path,2)
msgbox tstring
	tstream.write replace(tString,"<a href=""http://old.mydomain.com/index.html"" ></a>","<a href=""http://www.mydomain.com/index.html"" ></a>")
	tstream.close
end if
next

Open in new window

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

0
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.
0
CompTIA Cloud+

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

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

http://www.paulslore.com/utils/chgstr.zip

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

http://www.wingrep.com/

~bp
0

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.
0
knightEknightCommented:
chgstr.exe will do this in multiple files, and it traverses sub-folders.  For example:

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

~bp
0
mph23Author Commented:
Thanks for your help.

FYI - wingrep is $30.
0
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.