@echo off
fc 1.txt 2.txt>3.txt
setlocal enabledelayedexpansion
for /f %%a in (3.txt) do set file1=%%a !file1!
if %file%==""
(
goto end
)
else
(
copy test.xls e:\备份.xls
)
:end
[ Last edited by uemuem on 2006-10-14 at 01:17 ]作者: vkill 时间: 2006-10-14 01:02 for /f "tokens=*" %%a in (3.txt) do copy %%a e:\备份.xls
@echo off
setlocal enabledelayedexpansion
for /f %%a in (1.txt) do set file1=%%a !file1!
for /f %%a in (2.txt) do set file2=%%a !file2!
if "%file1%"=="%file2%"(
goto end
)else(
copy test.xls e:\备份.xls
)
:end作者: namejm 时间: 2006-10-14 06:14 如果还提示语法错误的话,估计有两个地方会出问题:
Originally posted by namejm at 2006-10-14 01:14:
if %file%=="" 属于语法格式错误,正确的应该是 if "%file%"=="" ,请注意加引号。
if %file%=="" 不属于语法格式错误,如果变量file的值就是""的话条件就成立。
错误的是(没有加在if %file%==""的后面。
另外7楼少打了几个空格
@echo off
setlocal enabledelayedexpansion
for /f %%a in (1.txt) do set file1=%%a !file1!
for /f %%a in (2.txt) do set file2=%%a !file2!
if "%file1%"=="%file2%" (
goto end
) else (
copy test.xls e:\备份.xls
)
:end
[ Last edited by qwe1234567 on 2006-10-16 at 22:37 ]作者: lxmxn 时间: 2006-10-17 04:48
楼上版主所言极是。