Hello daniweb members,
I hope you can assist me... My apologies for very rusty DOS knowledge.
The batch file I'm trying to write must...
... recognize which drive letter has been assigned by Windows to ONE USB memory stick
... format it according to very precise instructions.
So I've determined ...
A) how to display the drive information,
B) how to format the drive properly...
but I cannot close the gap between A and B. I don't remember how to make "b" understand which drive it should format:
A
@echo off
setlocal enabledelayedexpansion
set UsbNum=0
for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
for /f %%h in ('fsutil fsinfo drivetype %%a:^|findstr "Removable"') do (
set /a UsbNum+=1
set DriveU!UsbNum!=%%h
)
)
echo You have !UsbNum! removable drives, list as below:
for /l %%a in (1,1,!UsbNum!) do (
echo.!DriveU%%a!
)
endlocal
pause
B ("e:" is just there for the example)
format e: /x /fs:FAT /v:FORMATHISDRIVE_H12