I am trying to do an xcopy of files on a server then copy them to a location. I have the xcopy command working properly. My issue is trying to find out what the removable media drive will be. It could be any drive letter I have posted my code below. It works but it always copies and makes a folder on my desktop called drive. I need this code to search for the removable drive letter and then copy the files to that drive letter.
for %%a in (E,F,G,H,I,J) do call :testdrive %%a
REM use Dir to get drive label. Sets drive variable
for /f "tokens=5,*" %%x in ('dir %test%:\*.* 2^>NUL ^| find /i "volume in drive"') do if /i "%%y"=="%testfor%" set drive=%test%:
echo %testfor% drive is %drive%
xcopy "X:\Emergency Planning\test\*.*" "%drive\" /C/E/H/R/K/D/M/Y