I need to get the drive letter of the usb pen drive.the command CHDIR >drive.txt gives me the drive letter L:.How do I read/get this info \"L:\" without quotes into a variab
Whatever chdir outputs can also be used by the pseudo-variable %CD%. So you already have a variable with that information.
Otherwise you can use for:
for /f "delims=" %%x in ('chdir') do set "drive=%%x"
But I think %CD% is much easier :-)
EDIT: You said that with the quotes already. You won't have any quotes in the variable unless you want them in there.
As for the trailing backslash: You can use the following instead of %CD%:
%CD:~0,-1%
which will expand %CD% and remove the last character, which you know is the backslash.
Still, will only work if you're in the root directory of that drive. Otherwise you can also use
for %%x in (%cd%) do @set drive=%%~dx