Goal: Given string "CAR080 CAR085 CAR087" I need to iterate through all three cars and perform copying of files from the carname folder.
Need to copy files from individual car folders by looping through it. Code:
@echo off
set basesource=xyz\
set year=%date:~10,4%
set destination=C:\ARWISdata\year%year%
set tempDir=DATAARWIS\DATARP_%year%
set s= CAR080 CAR085 CAR087
set t=%s%
echo t:%t%
:loop
for /f "tokens=1*" %%a in ("%t%") do (
set temp1=%%a
set SLASH=\
echo basesource:%basesource%
echo temp1:%temp1%
set source=%basesource%%temp1%%SLASH%%tempDir%
echo source:%source%
IF EXIST %source% (echo source exists)
echo destination: %destination%
IF EXIST %destination% (echo destination exists) ELSE (mkdir C:\ARWISdata\year%year%)
for /f %%a in ('xcopy /S /E /Y /D "%source%" "%destination%" ') do (
echo.Copying file '%%a'
)
set t=%%b
)
if defined t goto :loop
but it is not giving me exact solution. As it needs to take first CAR080 and perform copy operation then in next cycle it should take CAR085 and perform copying and then finally CAR087.
Need the code urgently.