# Batch file command

**URL:** <https://boards.straightdope.com/t/batch-file-command/375305>\
**Category:** Factual Questions\
**Created:** [October 4, 2006, 8:49pm UTC](https://boards.straightdope.com/t/batch-file-command/375305 "2006-10-04T20:49:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Will\_Repair](https://avatars.discourse-cdn.com/v4/letter/w/a698b9/32.png) [@Will\_Repair](https://boards.straightdope.com/u/Will_Repair)\
**Post date:** [October 4, 2006, 8:49pm UTC](https://boards.straightdope.com/t/batch-file-command/375305/1 "2006-10-04T20:49:37Z")

</div>

What is the syntax for an automatic yes in a batch file.

Forinstance.bat  
format a:

produces a “‘y’ or ‘n’” dialogue.  
But there is a way around it.  
Can’t remember and can’t find it.

Something like:

Almostright.bat  
format a: \<\< “y”

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [October 4, 2006, 8:57pm UTC](https://boards.straightdope.com/t/batch-file-command/375305/2 "2006-10-04T20:57:10Z")

</div>

try format a: \< y

---

<div class="post-metadata">

**Author:** ![Ximenean](https://avatars.discourse-cdn.com/v4/letter/x/aca169/32.png) [@Ximenean](https://boards.straightdope.com/u/Ximenean)\
**Post date:** [October 4, 2006, 9:41pm UTC](https://boards.straightdope.com/t/batch-file-command/375305/3 "2006-10-04T21:41:33Z")

</div>

That should be **echo y ¦ format a:**. **Format a: \< y** would take the input to **format** from a file called y, if any such file existed.

---

<div class="post-metadata">

**Author:** ![Mangetout](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/mangetout/32/19_2.png) [@Mangetout](https://boards.straightdope.com/u/Mangetout)\
**Post date:** [October 4, 2006, 10:39pm UTC](https://boards.straightdope.com/t/batch-file-command/375305/4 "2006-10-04T22:39:45Z")

</div>

Usually, such switches are given follwing a forward slash, or a dash, but there’s no point in using a switch that isn’t one of the range specifically designed to work with the command in question, for example (in the command line of Windows XP), there isn’t any switch for the format command that would override the screen prompts. These are the available switches and command syntax options:

```auto

FORMAT volume [/FS:file-system] [/V:label] [/Q] [/A:size] [/C] [/X]
FORMAT volume [/V:label] [/Q] [/F:size]
FORMAT volume [/V:label] [/Q] [/T:tracks /N:sectors]
FORMAT volume [/V:label] [/Q]
FORMAT volume [/Q]

  volume Specifies the drive letter (followed by a colon),
                  mount point, or volume name.
  /FS:filesystem Specifies the type of the file system (FAT, FAT32, or NTFS).
  /V:label Specifies the volume label.
  /Q Performs a quick format.
  /C NTFS only: Files created on the new volume will be compressed
                  by default.
  /X Forces the volume to dismount first if necessary. All opened
                  handles to the volume would no longer be valid.
  /A:size Overrides the default allocation unit size. Default settings
                  are strongly recommended for general use.
                  NTFS supports 512, 1024, 2048, 4096, 8192, 16K, 32K, 64K.
                  FAT supports 512, 1024, 2048, 4096, 8192, 16K, 32K, 64K,
                  (128K, 256K for sector size > 512 bytes).
                  FAT32 supports 512, 1024, 2048, 4096, 8192, 16K, 32K, 64K,
                  (128K, 256K for sector size > 512 bytes).

                  Note that the FAT and FAT32 files systems impose the
                  following restrictions on the number of clusters on a volume:

                  FAT: Number of clusters <= 65526
                  FAT32: 65526 < Number of clusters < 4177918

                  Format will immediately stop processing if it decides that
                  the above requirements cannot be met using the specified
                  cluster size.

                  NTFS compression is not supported for allocation unit sizes
                  above 4096.

  /F:size Specifies the size of the floppy disk to format (1.44)
  /T:tracks Specifies the number of tracks per disk side.
  /N:sectors Specifies the number of sectors per track.

```

---

<div class="post-metadata">

**Author:** ![JimOfAllTrades](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@JimOfAllTrades](https://boards.straightdope.com/u/JimOfAllTrades)\
**Post date:** [October 5, 2006, 3:44am UTC](https://boards.straightdope.com/t/batch-file-command/375305/5 "2006-10-05T03:44:25Z")

</div>

**Usram** is correct, you could use the echo command in commands that don’t have an override command line switch, or you can use the redirector (the \<) along with a text file that has the response you want.

For example, to use the redirection approach, create a simple text file with nothing but the letter Y and a carriage return. Call it “y.txt”.

Then you can type (or put in a batch file)  
format a: \< y.txt

and away it goes.

---

<div class="post-metadata">

**Author:** ![Will\_Repair](https://avatars.discourse-cdn.com/v4/letter/w/a698b9/32.png) [@Will\_Repair](https://boards.straightdope.com/u/Will_Repair)\
**Post date:** [October 8, 2006, 6:47pm UTC](https://boards.straightdope.com/t/batch-file-command/375305/6 "2006-10-08T18:47:34Z")

</div>

Heres the deal: I’ve got an old Pentium laptop running Win98. Since hard disk space is at a premium I have a batch file to delete c:\windows emp which is not deleted by cleandisk.exe.

echo y | del c:\windows emp\*.\*  
Works.

echo y | deltree c:\windows emp\*.\*  
Doesn’t work. In fact it hangs the msdos window.  
And it creates it own directory in …/temp with a file with only an ‘y’.

Riddle me that, Batman!

---

<div class="post-metadata">

**Author:** ![yoyodyne](https://avatars.discourse-cdn.com/v4/letter/y/a9a28c/32.png) [@yoyodyne](https://boards.straightdope.com/u/yoyodyne)\
**Post date:** [October 8, 2006, 7:05pm UTC](https://boards.straightdope.com/t/batch-file-command/375305/7 "2006-10-08T19:05:44Z")

</div>

It’s easier than that. DELTREE takes a /y switch to run without confirmation.

DELTREE /Y c:\windows emp\*.\*
