USB CMD Formatting

dbuchan

Honorable
Aug 16, 2012
16
0
10,520
Im attempting to format USB drives that may or may not have the same drive letter at all times and then copy a specific file to them. For this Im writing a batch file but Im having a hard time finding a way to format the drive. I was hoping I could format the drives based on name or some other parameters.

format [drive:] /q /vol:Cruizer /fs:NTFS
copy C:\users\xxxxx\desktop\filename.dat [drive:]

Something like this is where Im heading to but the drive letter is my grief. If this was a networked drive or a drive with a static drive letter that would be another thing. I have thought about making the drives a static drive letter through windows disk management also.
 
Hmm seems it has a popup of sorts if linked from here.
Here's the transcript.

Batch file to automatically format drive
Asked by: maximus81Solved by: dragon-it
I am trying to create a script to automatically quick format a drive each day. So far I have this
but it asks me for the volume name and I pipe it in but its not working.


echo ExchBackups
echo Y| format b: /q /x /FS:NTFS /v:ExchBackups

Jump to Answer
ID: 27843233

Tags
batch file
,
bat
Topics
Windows Batch Scripting
,
MS DOS
,
VB Script
Comments
9

Comments


Expert Comment

by: Xaelian on 2012-08-27 at 06:31:53ID: 38336433
echo y | format E: /FS:NTFS /q

replace the E: with the volume you want to format.


Author Comment

by: maximus81 on 2012-08-27 at 06:36:20ID: 38336447
I get this after running this:

The type of the file system is NTFS.
Enter current volume label for drive B: y
An incorrect volume label was entered for this drive.


Expert Comment

by: xDUCKx on 2012-08-27 at 06:40:00ID: 38336462
8.3 naming convention. Your volume label is too long. Try

/v:Exch

That should do it. Or enclose it in quotes:

/v:"ExchBackup"


Expert Comment

by: Xaelian on 2012-08-27 at 06:45:47ID: 38336491
@echo off
format B: /q /autotest

the /autotest formats the drive without user interaction.


Expert Comment

by: dragon-it on 2012-08-27 at 07:08:31ID: 38336562
This works for me against a 1Gb USB stick, was FAT32 with a few files on changed label the ExchBackups then ran this:

C:\Users\stephen>echo ExchBackups|format f: /q /fs:NTFS /Y /v:ExchBackups

The type of the file system is NTFS.
QuickFormatting 959M
Creating file system structures.
Format complete.
960.0 MB total disk space.
952.9 MB are available.


Accepted Solution

by: dragon-it on 2012-08-27 at 07:10:57ID: 38336571
In fact using /Y you don't need to specify the volume name either:

format f: /q /fs:NTFS /Y /v:ExchBackups

Steve


Author Comment

by: maximus81 on 2012-08-27 at 07:42:02ID: 38336718
This worked. Thanks for the help

echo ExchBackups|format B: /FS:NTFS /Y /q /v:ExchBackups > C:\format.txt


Author Closing Comment

by: maximus81 on 2012-08-27 at 07:42:26ID: 38336721
Perfect. Thanks


Expert Comment

by: dragon-it on 2012-08-27 at 08:20:32ID: 38336908
No problem. I don't think the /y is listed in the help but it does work :)