. f_askdir.sh
. f_askstring.sh
ask_directory 1
if [ $? -eq 1 ]; then
exit 1
fi
echo "Target directory is \"${_DIRNAME}\""
ask_string "Input delete extension: " 0
EXTENSION=$_STR
echo "Delete Extension is \"${EXTENSION}\""
NUM=0
for FNAME in $_DIRNAME/*.$EXTENSION; do
if [ -f "$FNAME" ]; then
mv $FNAME ${FNAME%.$EXTENSION}
NUM=$(expr $NUM + 1)
fi
done
if [ $NUM -eq 0 ]; then
echo "NO file."
else
echo "*** Successful."
fi
unset _DIRNAME EXTENSION FNAME NUM _STR
$ ls
ab1.text ab2.text ab3.text ab4.text ab5.text
$ ./del_extension.sh
Input Directory (Blank is Cancel.) : .
Target directory is "."
Input delete extension: text
Delete Extension is "text"
*** Successful.
$ ls
ab1 ab2 ab3 ab4 ab5