kosbou
kosbou

Reputation: 3999

how to set var in batch file

How to use the below variable

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

in xcopy command?

I use the below code

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

but i receive

file not found - *.txt

here is my code

    @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

Upvotes: 1

Views: 1263

Answers (1)

gammay
gammay

Reputation: 6215

Remove the spaces in SET command

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

Upvotes: 3

Related Questions