j*****h 发帖数: 6 | 1 大家好!我第一次来这里。还不太找得到方向。有一个问题想要帮
一 个朋友请问大家
不知道贴在这里有没有人可以帮我解答一下?先谢过了!
-----------------------------------------------------------
- ------------
The script, "rename", is called with 2 or 3 parameters. It
changes all files
with a given extension to another extension (only changes
the extension). The
first parameter is the extension that will be changed, the
second parameter is
the new extension; they are both specified without a dot.
If the third
parameter, the path to a directory, is not | B**z 发帖数: 153 | 2 #!/bin/ksh
if [ $# -lt 2 -o $# -gt 3 ];then
echo "Usage:$0 ext newext [path]"
exit 1
fi
if [ $# -eq 2 ];then
DIR=.
else
if [ -d $3 ];then
DIR=$3
else
echo "$3 does not exit."
exit 2
fi
fi
oldext=$1
newext=$2
((fileschanged=0))
files=$DIR/*.$oldext
for afile in $files;do
if [ -f $afile ];then
mv $afile ${afile%$oldext}$newext
((fileschanged=fileschanged+1))
fi
done
echo "$fileschanged \c"
if [ $fileschanged -gt 1 ];then
echo "files changed."
else
echo "file changed.
【在 j*****h 的大作中提到】 : 大家好!我第一次来这里。还不太找得到方向。有一个问题想要帮 : 一 个朋友请问大家 : 不知道贴在这里有没有人可以帮我解答一下?先谢过了! : ----------------------------------------------------------- : - ------------ : The script, "rename", is called with 2 or 3 parameters. It : changes all files : with a given extension to another extension (only changes : the extension). The : first parameter is the extension that will be changed, the
|
|