Home > Mobile >  Passing messy file variables to robocopy
Passing messy file variables to robocopy

Time:12-13

I'm trying to pass a set of variables to robocopy, all variables contain spaces and are potentially very long. I need to be able to wrap arguments in a manner that enables robocopy capturing full path.

:: Define array of input files to copy
set "MASTER_SOURCE=\\path\with\some file\and messy. folder name\bla bla --- bla\stuff"
set "SOURCE_FILES[0]=%MASTER_SOURCE%\this file with a pesky name.csv"
set "SOURCE_FILES[1]=%MASTER_SOURCE%\this other file with a pesky name.csv"

:: Define output file path
SET "OUTPUT_ROOT=C:\Users\me\stuff and things\save here"

:: Create dated folder within the OUTPUT_ROOT location
:: Obtain date/time timestamps
:: Source: https://stackoverflow.com/a/19706067/1655567
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "datestamp=%YYYY%%MM%           
  • Related