如何在批处理文件中设置var

时间:2012-10-04 17:30:09

标签: windows batch-file xcopy

如何使用以下变量

SET DESKTOP_PATH = C:\Users\Kostas\Desktop\ToMobile
SET MOBILE_PATH = H:\koinoxrista
xcopy命令中的

我使用以下代码

xcopy %DESKTOP_PATH%\*.txt %MOBILE_PATH% /v

但我收到了

file not found - *.txt

这是我的代码

    @echo off

SET DESKTOP_PATH = C:\Users\Kostas\Desktop\ToMobile
SET MOBILE_PATH = H:\koinoxrista

chdir \
chdir /d h:\koinoxrista

SET "FLAG="

IF EXIST Bill.txt SET FLAG=1
IF EXIST BillPayments.txt SET FLAG=1
IF EXIST Collector.txt SET FLAG=1
IF EXIST CompanyInfo.txt  SET FLAG=1
IF EXIST Expense.txt  SET FLAG=1
IF EXIST ExpensePayments.txt  SET FLAG=1
IF EXIST FlatComments.txt  SET FLAG=1
IF EXIST FlatMetric.txt  SET FLAG=1

IF DEFINED FLAG (ECHO Error!) ELSE (xcopy %DESKTOP_PATH%\*.txt %MOBILE_PATH% /v /w)

pause

1 个答案:

答案 0 :(得分:3)

删除SET命令中的空格

SET DESKTOP_PATH=C:\Users\Kostas\Desktop\ToMobile
SET MOBILE_PATH=H:\koinoxrista