- 论坛徽章:
- 0
|
hmkart,大侠,您刚才给的script我试过了,有些问题啊。
我想要一次修改几千个文件名,您的script只能一次一个啊。
#!/bin/sh
# This Shell Script can change low-case filename to UPPER-CASE filename.
# init the vars!
error=0;count=0
number=$(echo $* | /usr/bin/wc -w)
# end of the "init the vars"!
# process the parameter(s)!
if [ "$1" = "-h" -o "$1" = "--help" ]; then
echo "Usage: $0 [path] [filename]..."
echo "Description: Change \"filename\" to \"FILENAME\"!"
echo ""
echo " -h, --help display this info and exit"
echo " -v, --version display version info and exit"
echo ""
echo "Report bugs to <sea___sky@sina.com>."
echo "S: I think U can modify it by nothing! It's just a shell script! "
exit 0
fi
if [ "$1" = "-v" -o "$1" = "--version" ];then
echo "lowks2upks (a tool form my file-utils) ver0.1a"
echo "Written by Juner.L"
echo ""
echo "Copyright (C) Juner"
echo "This is free software; see the source for copying conditions. There is NO"
echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
exit 0
fi
# end of the "process the parameter(s)"!
# working part!
if [ -z "$1" ]; then
/usr/bin/printf "\a"
echo "Just put the \"filename\" follow the command!"
else
for i in $*
do
declare -x filez=$(echo $i | /bin/awk BEGIN'{FS="/"} {print $NF}')
pathz=$(echo $i | /bin/awk BEGIN'{FS=ENVIRON["filez"]} {print $1}')
if [ -e "$i" -a -w "$i" ]; then
file=$(echo $filez | /usr/bin/tr "[A-Z]" "[a-z]"
if [ "$filez" = "$file" ]; then
echo "THE FILE \"$i\" IS ALREADY UPPERCASED!"
count=$(/usr/bin/expr 1 + $count)
else
echo "$pathz$filez => $pathz$file"
/bin/mv -f $pathz$filez $pathz$file 2> /dev/null
fi
else
echo "WARING: FILE \"$i\" NOT EXIST or YOU HAVE NO \"w\" RIGHT TO FILE!"
fi
done
if [ "$number" -eq "$count" ]; then
echo " ALL FILE(S) IS UPPERCASED!"
else
echo " $count FILE(S) ALREADY UPPERCASED!"
fi
fi
# end of the "working part"! |
|