如果是批处理循环

时间:2016-06-20 12:32:07

标签: batch-file

我试图创建一个简单的批处理文件来检查当天,如果当天是01,程序会将文件移动到备份。

IF %day%==01(
move *.LST &dfs#\BackUp\
echo "Files moved successfully"
)ELSE (
"Files will get deleted only on 1st day of the month"
)

但它会抛出错误"语法不正确",有人可以查看..

1 个答案:

答案 0 :(得分:1)

可能%day%设置不正确,请尝试此操作(调整备份位置):

@echo off
if %date:~-2%==01 ( 
    move *.lst backup
    echo files moved successfully
) else (
    echo files will get deleted only on 1st day of the month
)