请会写windows批处理文件和shell脚本的大神帮忙将这个shell脚本转换成批处理文件
#!/bin/sh#onepara.clean_flag=0#makecleanecho"输入参数:$*"whilegetopts"C"argdocase$arginC)...
#!/bin/sh
# one para.
clean_flag=0 # make clean
echo "输入参数: $*"
while getopts "C" arg
do
case $arg in
C)
echo "arg: C"
clean_flag=1
;;
esac
done
if [ $# -eq 1 ] ; then
if [ $clean_flag == 1 ]; then
echo "clean tools..."
rm -rf translateTools/*
else
echo "Input param error!"
fi
echo "<<<<Exit!>>>>"
exit 1;
fi
# two para.
if [ $# != 3 ] ; then
echo " Error: Input parameter is incorrect!"
exit 1;
fi
TS_DIR=$(pwd)/qt_ts
CUR_TS_FILE=${TS_DIR}/qt_ts.ts
if test -d ${TS_DIR}
then
echo " Dir is yes"
else
mkdir ${TS_DIR}
fi
if [ -f $CUR_TS_FILE ]
then
rm $CUR_TS_FILE
fi
if [ -f $1 ]
then
lupdate $1 -ts $CUR_TS_FILE
else
echo " The file:$1 isn't exist which you input, exit!"
exit 1
fi
sync
echo " pwd:$(pwd)"
XLS_DIR=$(pwd)/language
CUR_XLS_FILE=${XLS_DIR}/res_language_translate_120.xls
translateTools/iMac120Translate_win.exe $CUR_XLS_FILE $CUR_TS_FILE $XLS_DIR/res_language_translate_120.ts $3
lrelease $XLS_DIR/res_language_translate_120.ts
#sleep 1
#cp ${CUR_TS_FILE} ${TS_DIR}/qt_ts_check.ts
#rm ${CUR_TS_FILE}
#rm ${TS_DIR} -rf
#rm $XLS_DIR/res_language_translate_120.ts
echo " Output qm file: [ $2 ]"
mv $XLS_DIR/res_language_translate_120.qm $XLS_DIR/$2
echo " copy to local..."
mkdir $(dirname $1)/language
cp $XLS_DIR/$2 $(dirname $1)/language/
echo " <<<<End qm output>>>>"
自己摸索着写了一大半,不麻烦大家帮忙全部转换了。现在问题有所改变,
if exist %1(
......
) else (
echo The file:"%1" isn't exist which you input, exit!
)
其中“%1”是我用命令行传入的一个文件路径
这句用bat怎么写,为什么我老是提示“命令语法不正确”?
如果改成if exist“%1”,则输出The file:"" isn't exist which you input, exit,%1显示,求正确写法 展开
# one para.
clean_flag=0 # make clean
echo "输入参数: $*"
while getopts "C" arg
do
case $arg in
C)
echo "arg: C"
clean_flag=1
;;
esac
done
if [ $# -eq 1 ] ; then
if [ $clean_flag == 1 ]; then
echo "clean tools..."
rm -rf translateTools/*
else
echo "Input param error!"
fi
echo "<<<<Exit!>>>>"
exit 1;
fi
# two para.
if [ $# != 3 ] ; then
echo " Error: Input parameter is incorrect!"
exit 1;
fi
TS_DIR=$(pwd)/qt_ts
CUR_TS_FILE=${TS_DIR}/qt_ts.ts
if test -d ${TS_DIR}
then
echo " Dir is yes"
else
mkdir ${TS_DIR}
fi
if [ -f $CUR_TS_FILE ]
then
rm $CUR_TS_FILE
fi
if [ -f $1 ]
then
lupdate $1 -ts $CUR_TS_FILE
else
echo " The file:$1 isn't exist which you input, exit!"
exit 1
fi
sync
echo " pwd:$(pwd)"
XLS_DIR=$(pwd)/language
CUR_XLS_FILE=${XLS_DIR}/res_language_translate_120.xls
translateTools/iMac120Translate_win.exe $CUR_XLS_FILE $CUR_TS_FILE $XLS_DIR/res_language_translate_120.ts $3
lrelease $XLS_DIR/res_language_translate_120.ts
#sleep 1
#cp ${CUR_TS_FILE} ${TS_DIR}/qt_ts_check.ts
#rm ${CUR_TS_FILE}
#rm ${TS_DIR} -rf
#rm $XLS_DIR/res_language_translate_120.ts
echo " Output qm file: [ $2 ]"
mv $XLS_DIR/res_language_translate_120.qm $XLS_DIR/$2
echo " copy to local..."
mkdir $(dirname $1)/language
cp $XLS_DIR/$2 $(dirname $1)/language/
echo " <<<<End qm output>>>>"
自己摸索着写了一大半,不麻烦大家帮忙全部转换了。现在问题有所改变,
if exist %1(
......
) else (
echo The file:"%1" isn't exist which you input, exit!
)
其中“%1”是我用命令行传入的一个文件路径
这句用bat怎么写,为什么我老是提示“命令语法不正确”?
如果改成if exist“%1”,则输出The file:"" isn't exist which you input, exit,%1显示,求正确写法 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询