I'm trying to write a batch file to xcopy a folder to a removable USB drive. The problem that I face, however, is that drive letters are subject to change, so I would like to be able to do this by referencing the volume label instead of the drive letter.
Any ideas? An hour of Google-ing has proved fruitless. :(
This command should discover the drive with the correct label and store the drive letter (with colon) in variable "usb"
for /f %%D in ('wmic volume get DriveLetter^, Label ^| find "yourLabel"') do set usb=%%D
You could embed your xcopy command(s) directly in the DO clause if you like. %%D contains the drive letter.