Shell Scripting and Regex Voodoo.
April 1, 2005 9:22 AM
Subscribe
I've got a problem. There is this ASP website that has gone down for repairs. I've got a wget of the whole site and i need to put the mirror back up on the internet. I've got Os X, and Developer tools installed, etc. I need a shell script to help me get this done.
The files are saved in a directory format.
\site.com\page.asp
\site.com\page.asp?random_info
\site.com\foo\otherpage.asp?random_bar
Etc.
I need to recursivle go through the folder and all subfolders, finding any filename that contains *.asp* and append ".html" to the end of the file.
so \site.com\foo\otherpage.asp?bar
becomes
\site.com\foo\otherpage.asp?bar.html
Thats part one.
Part two involves searching through the files themselves, and looking for links that contain *.asp*
i.e. [a href="\otherpage.asp?foobar"]link to foobar[/a]
and change it to:
[a href="otherpage.asp?foobar.html"] link to foobar[/a]
Thanks for any help you can provide.
posted by Freen to computers & internet (4 comments total)
There are plenty of old threads about batch renaming files. For the text editing, I'd reccomend you download TextWrangler and use batch grep.
Replace "(\S+\.asp[^"]*)" with "\1.html" (include the quote marks).
posted by cillit bang at 9:33 AM on April 1, 2005