# START -- how-to search and replace recursively in file paths and contents
export dir=/var/aktia/3rdparty/docs/docx;
export to_srch="emric"
export to_repl="t24"
#-- search and replace in file names, skip those in .git
find "$dir/" -not -path "./.git/*" -type d |\
perl -nle '$o=$_;s#'"$to_srch"'#'"$to_repl"'#g;$n=$_;`mkdir -p $n` ;'
find "$dir/" -not -path "./.git/*" -type f |\
perl -nle '$o=$_;s#'"$to_srch"'#'"$to_repl"'#g;$n=$_;rename($o,$n) unless -e $n ;'
#-- search and replace in file contents, skip those in .git
find "$dir/" -not -path "./.git/*" -type f -exec perl -pi -e "s#$to_srch#$to_repl#g" {} \;
find "$dir/" -not -path "./.git/*" -type f -name '*.bak' | xargs rm -f"
# STOP -- how-to rename files recursively in file paths and contents