Skip to content

Instantly share code, notes, and snippets.

@sureshamk
Last active December 2, 2016 18:29
Show Gist options
  • Save sureshamk/74cad5c36c2817cf2343fb58c04a6ed4 to your computer and use it in GitHub Desktop.
Save sureshamk/74cad5c36c2817cf2343fb58c04a6ed4 to your computer and use it in GitHub Desktop.
rename files with suffex in middle
# test
find . -name "*.class.php" -type f -exec rename -n 's/\.class.php$/\.php/' *.php '{}' \;
# execute
find . -name "*.class.php" -type f -exec rename 's/\.class.php$/\.php/' *.php '{}' \;
#!/usr/bin/env bash
#find . -name "*.php" -type f
#for file in $(find . -name "*.php" -type f)
#do
## echo $file
# if grep -q PluginBase "$file"; then
# filename=$(basename "$file")
# fname="${filename%.*}"
# #echo $fname
#
# namespace1=" namespace "
# namespace2="App\\\\Plugins\\\\"
# namespace3=${fname};
# namespace4=";\n\nuse App\\\\Plugins\\\\PluginBase;"
# final=$namespace1$namespace2$namespace3$namespace4
# echo $file
# sed -i "2 i $final" $file
# fi
#done
for file in $(find . -name "*.php" -type f)
do
# echo $file
#echo $file
if grep -L namespace "$file"; then
if grep -q class "$file"; then
echo $file
fi
filename=$(basename "$file")
fname="${filename%.*}"
#echo $fname
#exit;
#exit;
# if grep -q ServiceException "$file"; then
# filename=$(basename "$file")
# fname="${filename%.*}"
# echo $fname
#exit;
# namespace1=" namespace "
# namespace2="App\\\\Plugins\\\\"
# namespace3=${fname};
# namespace4=";\n\nuse App\\\\Plugins\\\\PluginBase;"
# final=$namespace1$namespace2$namespace3$namespace4
# echo $file
# sed -i "2 i $final" $file
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment