I have a CMD file used to create backups from my C: drive to a user-designated USB drive. The fundamentals are working fine, but a small refinement I'd like to add is giving me a problem.
At the beginning of the CMD, I get the port where the USB device is located using the SET /p new_variable= construct: this works fine.
Say the name of this variable is M_drive1 (the drive letter).
Later I create another new_variable (to use in the XCOPY command that does the actual "backup"). That new_variable is created using this construct: SET M_outdrive=%M_drive1%:?
So if the user enters "m" (no quotes) to the request for drive letter, then M_drive1 contains the letter m, and M_outdrive contains m:\.
The CMD file then verifies that the named drive is valid (exists) and aborts if not.
All the above works as intended.
At this point I'd like to display the USB disk volume label. So I want to create a variable to pass to the Vol command. For that I use the command: SET M_vol=%M_drive1%:.
But that creates a variable M_vol that just contains the colon ... no drive letter.
Can someone tell me what I'm doing wrong?
At the beginning of the CMD, I get the port where the USB device is located using the SET /p new_variable= construct: this works fine.
Say the name of this variable is M_drive1 (the drive letter).
Later I create another new_variable (to use in the XCOPY command that does the actual "backup"). That new_variable is created using this construct: SET M_outdrive=%M_drive1%:?
So if the user enters "m" (no quotes) to the request for drive letter, then M_drive1 contains the letter m, and M_outdrive contains m:\.
The CMD file then verifies that the named drive is valid (exists) and aborts if not.
All the above works as intended.
At this point I'd like to display the USB disk volume label. So I want to create a variable to pass to the Vol command. For that I use the command: SET M_vol=%M_drive1%:.
But that creates a variable M_vol that just contains the colon ... no drive letter.
Can someone tell me what I'm doing wrong?