Skip to content

Instantly share code, notes, and snippets.

@cdracars
Last active December 17, 2015 10:28
Show Gist options
  • Save cdracars/5594846 to your computer and use it in GitHub Desktop.
Save cdracars/5594846 to your computer and use it in GitHub Desktop.
Drupal Module Rename Code.
#!/bin/bash
# Module Rename script. Written by cdracars 2013
NAME=`find . -type f -name *.module | cut -c 3- | cut -d'.' -f1`
echo "Please enter a new name for the module."
read VAR
VAR1='windows' # String to be found.
VAR2='liniux' # String that will replace found string.
# Replace all instances of found string in file names.
for f in *; do
mv $f `echo $f | sed "s/$NAME\(.*\)/$VAR\1/g"`;
done
# Replace all instances of found string in content of files.
grep -rl $NAME ./ | xargs sed -i '' "s/$NAME/$VAR/g"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment