# Command: defrag

      DEFRAG optimizes file loading times from a disk by moving file
      fragments together.

## Syntax:

      defrag [/C] [drive] [{/F|/U|/DF|/FF|/FD}] [/Sorder[-]] [/B] [/X] [/A]
             [/FO] [/?]
             drive  This is the drive letter of the drive you wish to
                    defragment. For instance: defrag c:

#### [Main menu] [top] (Syntax) [Options] [Comments] [Examples] [See also] [File]

## Options:

      /C   Use command line version only. Defrag will not use its
           menu-driven user interface if you use this option. It will
           communicate through the command line instead.
           You must use the [drive] option, as described above,
           when you use the /C switch, e.g. defrag /c c:
      /F   Fully optimizes specified drive. With this option, defrag will
           perform a full optimization by making sure that all files are
           at the beginning of the disk, with no gaps in between.
      /U   With this option, defrag will unfragment the files, but
           gaps may be left between files.
      /FF  Fully optimized the drive, moving all files first.
      /DF  Fully optimized the drive, moving all directories first.
      /FD  Fully optimized the drive, moving all files of the same directory
           together.
      /S   Sort files by specified order.
           order: N  by Name (alphabetic)
                  E  by Extension (alphabetic)
                  D  by Date and time (earliest first)
                  S  by Size (smallest first)
                  -  suffix to sort in descending order.
      /B   Reboots the computer after the optimization.
      /X   Forces defrag to exit as soon as it completes the optimization.
      /A   For use with the /C option, defrag will give an audible warning
           before taking action.
      /FO  For use with the /C option, this tells defrag to give a more full
           output of information.
      /?   Shows the help.

#### [Main menu] [top] [Syntax] (Options) [Comments] [Examples] [See also] [File]

## Comments:

      Type DEFRAG /no-ops for a list of no-ops (/SKIPHIGH, /LCD, /BW, /GO).
      Type DEFRAG /contrib for a list of contributors.
      It is recommended to use DEFRAG with the user interface (not: /C).
      What is disk fragmentation?
      When files are deleted, or made smaller, this leaves gaps in the data
      stored on the disk. If a file is created, or increases in size, it will
      go in the gaps, but if this space isn't big enough, the file will be
      continued elsewhere on the disk. After many such operations the file data
      can become very scattered. This fragmentation process slows down file
      access. Fragmentation is a normal process on DOS disks.

      When should I use defrag?
      Use defrag occasionally, or after installation of larger programs or
      after the creation of many (small) files.
      DEFRAG has the following EXITCODES (ERRORLEVEL):
        0  success
        1  internal error
        2  disk too full to defrag
        3  aborted by user
        4  general error
        5  read error
        6  write error
        7  FAT allocation error
        8  memory error
        9  out of memory

#### [Main menu] [top] [Syntax] [Options] (Comments) [Examples] [See also] [File]

## Examples:

      defrag c: /F

#### [Main menu] [top] [Syntax] [Options] [Comments] (Examples) [See also] [File]

## See also:

      chkdsk
      dosfsck
     (scandisk)

#### [Main menu] [top] [Syntax] [Options] [Comments] [Examples] (See also) [File]

## File:

      Please read this command's lsm file also.
      You will find the updated version (internet) here and
      the version described in this manual page here.
      The lsm file contains information about the name of the programmer,
      the download site, and some other command related information.

#### [Main menu] [top] [Syntax] [Options] [Comments] [Examples] [See also] (File)

      Copyright © 2003 - 2004 Robert Platt, updated 2011 by W. Spiegl.

      This file is derived from the FreeDOS Spec Command HOWTO.
      See the file H2Cpying for copying conditions.