Skip to content

Instantly share code, notes, and snippets.

@lisotton
Created January 19, 2015 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lisotton/ed30572e0d84089dfeae to your computer and use it in GitHub Desktop.
Save lisotton/ed30572e0d84089dfeae to your computer and use it in GitHub Desktop.
Add project name to all Drupal modules
#!/bin/bash
# Find modules without project
INFOS=`find sites/*/modules -name '*.info' | xargs -I {} grep -iL 'project' {}`
for INFO in $INFOS; do
PROJECT=`basename $INFO | sed 's/\.info//'`
echo "Add \"project = $PROJECT\" in: $INFO ? [Y/n]"
read yes_no
if [ "$yes_no" != "n" ]; then
echo -e "\nproject = $PROJECT" >> $INFO
fi
done
# Find modules with "project=drupal"
INFOS=`find sites/*/modules -name '*.info' | xargs -I {} grep -il 'project.*drupal' {}`
for INFO in $INFOS; do
PROJECT=`basename $INFO | sed 's/\.info//'`
echo "Replace \"project=drupal\" to \"project = $PROJECT\" in: $INFO ? [Y/n]"
read yes_no
if [ "$yes_no" != "n" ]; then
sed -i "s/project.*drupal.*/project = $PROJECT/" $INFO
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment