Last active
April 12, 2018 13:54
-
-
Save 2jiwon/1dad9a100bb886f8e7dc492ee24070d4 to your computer and use it in GitHub Desktop.
A Bash Shell Script to find ".aaa" files recursively in a directory, then rename the files as ".bbb".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
num = 0 | |
for file in $(find ./* -name '*.sgk' | grep -n 'sgk$') | |
do | |
(( num++ )) | |
echo "$file" | |
done | |
echo -e '\n' "Searched $num files.\n" | |
answer="N" | |
echo -n "Is this result right? Do you want to change the file names? (y/N)" | |
read answer | |
if [[ "$answer" == [Yy] ]] | |
then | |
for file in $(find ./* -name '*.sgk' | grep 'sgk$') | |
¦ do | |
¦ ¦ ¦ mv "$file" "${file%.sgk}.php" | |
¦ done | |
if [[ $? == "0" ]]; then | |
¦ echo -e "Done.\n" | |
fi | |
else | |
echo -e "Okay,bye... \n" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment