0

I am using Loop.bat to call copy.bat as given below

Loop.bat

FOR %%G IN (2 3 4) DO COPY.bat %%G

Copy.bat

@echo OFF
setlocal ENABLEDELAYEDEXPANSION
SET DIR = C:\B%1_DATA\
for %%s in (^
 !DIR!B%1_File1.dat^
 !DIR!B%1_File2.dat )^
do xcopy /y %%s C:\Temp 

The %%S appears as B2_File1.dat

I want to append the directory path so that it becomes C:\B2_DATA\B2_File1.dat

Why isn't DIR variable not recognized inside for loop? I have also tried %DIR%.

lostpacket
  • 1,383
  • 8
  • 26
  • 38
  • 3
    because there is no variable `dir`. You defined a variable `dir `. Remove the spaces around `=`. They become part of the variable name / value. – Stephan Jul 31 '17 at 19:21

1 Answers1

0

Thanks, @Stephan for pointing it out. I removed space between DIR and = and its working now.

lostpacket
  • 1,383
  • 8
  • 26
  • 38