If you're commonly editing website file contents you should invest in an editor.
Drop the website onto the icon and it will build the project:
run cmdshiftF and enter the replacement:
Replace button and verify the
It will open and change all the files:
Is an excellent and robust application I primarily use to edit code. Drag and drop the folder onto BBEdit and go to
File -> Save Project and it will create a file named
run cmdshiftF and select the project with the replacement parameters:
It will prompt you after clicking
If you are unsure on your changes select
Leave Open because if you select
Save to disk it is very hard to revert back.
There is already a
sed solution but you could also do the same with Perl:
if [ ! -e "$DIR/new" ]; then
mkdir -p new
echo "made folder new"
echo "folder exists"
for htmlfile in $(ls "$DIR"/*.html); do
echo "Working on "$htmlbase
perl -pe 's|www.website.com|www.website.com\/old|g' "$htmlfile" > $TEMPFILE && mv $TEMPFILE "$NEW/$htmlbase"
There are other editors out there but these are the two I primarily use. You could also do this in pure AppleScript but you haven't shown any code and mentioned terminal so I made the above in Perl.