Renaming within filenames
I have renamed a Moodle module I’m writing from mod_dumgalinduction to mod_dumgalchecklist because it seems to have more use beyond the original idea (move the student induction checklist off the paper form).
To search and replace all of the text within the php files is quite easy:
find . -type f -exec sed -i -e 's/induction/checklist/g' {} \;
find . -type f -exec sed -i -e 's/Induction/Checklist/g' {} \;
find . -type f -exec sed -i -e 's/INDUCTION/CHECKLIST/g' {} \;
I renamed the lang file from dumgalinduction.php to dumgalchecklist.php manually. I always get in a muddle changing the names of the files in the backup folder so I used this rename command to check what would happen before actually doing the rename:
$ rename -n 's/induction/checklist/' *.php
rename(backup_dumgalinduction_activity_task.class.php, backup_dumgalchecklist_activity_task.class.php)
rename(backup_dumgalinduction_stepslib.php, backup_dumgalchecklist_stepslib.php)
rename(restore_dumgalinduction_activity_task.class.php, restore_dumgalchecklist_activity_task.class.php)
rename(restore_dumgalinduction_stepslib.php, restore_dumgalchecklist_stepslib.php)
Looks reasonable so now just execute this:
$ rename 's/induction/checklist/' *.php
Result looks good:
backup_dumgalchecklist_activity_task.class.php restore_dumgalchecklist_activity_task.class.php
backup_dumgalchecklist_stepslib.php restore_dumgalchecklist_stepslib.php