#!/bin/sh
#
# RestoreBackupFiles
# Bourne shell script, should work on any Unix-based platform
#
# Recursively renames all *.backup files to their original names
# (the part before ".backup").  For example, to roll back
# changes in which the original files were renamed with a
# suffix of ".backup" (e.g. by the ChangeURL script).
#
# Install this file in any directory in your PATH (or any other
# directory, if you don't mind invoking it by specific pathname).
# Give it execute permission:
#
#   cd (directory where you saved this this)
#   chmod +x RestoreBackupFiles
#
# To run, cd to the directory where the "*.backup" files are
# (which can be a flat directory or the root of a directory tree)
# and then type:
#
#   RestoreBackupFiles
#
# Author: Frank da Cruz, 4 June 2017
#
for i in `find . -name \*.backup -print`; do
   echo -n $i " => "
   x=`echo $i | sed "s/.backup$//"`
   mv $i $x || exit 1
   echo $x
done
exit
