Created
August 10, 2010 12:14
-
-
Save jaymzcd/517167 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Finds all ASP files in the current folder and below and turns the include | |
# definition into a PHP format one. The converted file is renamed to FILE.php | |
# and the original file removed. Links in the format 'href="file.asp"' *only* | |
# are changed to 'href="file.php"'. It then loops through to fix .asp | |
# links in plain HTML files - this fits my use-case. | |
for FILE in $(find ./ -name "*.asp") | |
do | |
sed -e 's/<!--#include file="\(.*\)"-->/<?php include("\1"); ?>/g' $FILE > /tmp/includes.asp; | |
sed -e 's/href="\([[:alnum:]_-]*\).asp"/href="\1.php"/g' /tmp/includes.asp > /tmp/out.asp | |
mv /tmp/out.asp `basename $FILE .asp`.php; | |
rm -f $FILE; | |
echo "Converted includes & renamed $FILE"; | |
done | |
for FILE in $(find ./ -name "*.html") | |
do | |
sed -e 's/href="\([[:alnum:]_-]*\).asp"/href="\1.php"/g' $FILE > /tmp/out.html | |
mv /tmp/out.html $FILE; | |
echo "Updated links in $FILE"; | |
done | |
echo "COMPLETE"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment