batch file - FOR /F not outputting correctly wen using move in the loop -
i'm trying clean few file shares, , have list of folders i'm trying move in csv file.
values in delfromtest.csv
test1 test2 test3
i'm attempting use this.
for /f "tokens=1" %%a in (c:\delfromtest.csv) ( if exist %drive%:\%%~a (set asset=%%~a%) move "%drive%:\images%drive%\%asset%" "%drive%:\images%drive%\do not migrate%drive%\%asset%" )
this outputs
move "v:\imagesv\c:\delfromtest.csv" "v:\imagesv\do not migratev\c:\delfromtest.csv"
but if remove entire move command loop, variables output desired.
try for
without quotes or use usebackq. enable delayedexpansion when variable set , within for
@echo off setlocal enabledelayedexpansion /f %%a in (c:\delfromtest.csv) ( set asset=%%~a if exist %drive%:\!asset! ( echo move "%drive%:\images%drive%\!asset!" "%drive%:\images%drive%\do not migrate%drive%\!asset!" ) ) exit /b 0
Comments
Post a Comment