Automate file text edits

automatorhtmlscripttext-editorwebsites

I have an online website that I'd like to move to a new URL.
Therefore I need to edit all website html files (100+ files) to update the URL links inside each file of this website.

I'm thinking of making an off-line copy of the website files to edit.

Is it possibile to use Automator OS X to
– open each file in the website file folder
– search inside the file content for a specific URL link (say "www.website.com") and change it to the new URL (say "www.website.com/old")?

Else, do I need to rely on a text editor + Automator to make this process?

Or, can it be done using a UNIX script that you run in the Terminal ?

Thanks for any advice on how to perform this process!

Best Answer

Assuming all files are in the same folder:

mkdir new
for i in *.html; do
    sed 's|website.com|website.com/old|g' "$i" > "new/$i"
done