0

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
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by CWorl
0

In A starting in your last loop under your echo.!DriveU%%a!:

set thdrive=!DriveU%%a!
)
echo format %thdrive% /x /fs:FAT /v:FORMATHISDRIVE_H12>formatit.bat
call formatit.bat
del /f formatit.bat
endlocal
pause
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.