ultradefrag.sourceforge.net
The UltraDefrag Handbook  5.0.0
Console Interface

The UltraDefrag installer places the command line tool udefrag.exe into the System32 directory. Therefore it may be run without specifying the full path. View screenshots...

Command line options

Usage:

 udefrag [command] [options] [volumeletter:] [path(s)]

Commands:

-a, --analyze
Analyze the volume.
--defragment
Defragment the volume. This key is optional. Specifying just the volume letter will cause UltraDefrag to defragment the volume.
-o, --optimize
Optimize the volume space by moving all files to the beginning of the volume.
--quick-optimize
Optimize the volume space by moving not fragmented files to the beginning of the volume.
-l, --list-available-volumes
List all volumes available for defragmentation, except removable. Each line of the output contains a volume letter, filesystem name, total space and amount of free space.
-la, --list-available-volumes=all
List all volumes available for defragmentation, including removable.
-h, -?, --help
Show help screen. Running UltraDefrag without arguments has the same effect.

Options:

-b, --use-system-color-scheme
Use system color scheme (usually black/white) instead of the green color.
-p, --suppress-progress-indicator
Hide progress indicator.
-v, --show-volume-information
Show volume information after a job completes.
-m, --show-cluster-map
Show a map representing clusters of the volume.
--map-border-color=color
Set cluster map border color. Available values: black, white, red, green, blue, yellow, magenta, cyan, darkred, darkgreen, darkblue, darkyellow, darkmagenta, darkcyan, gray. Yellow color is used by default.
--map-symbol=x
Set the character used for the map drawing. There are two accepted formats: a character may be typed directly, or its hexadecimal number may be used. For example, --map-symbol=0x1 forces UltraDefrag to use a smile character for the map drawing. Valid numbers are in the range of 0x1 to 0xFF. The % symbol is used by default.
--map-rows=n
Number of rows of the cluster map. Default value is 10.
--map-symbols-per-line=n
Number of map symbols contained in each row of the map. Default value is 68.
--use-entire-window
Expand cluster map to use entire console window.
--wait
Wait until already running instance of UltraDefrag completes before starting the job (useful for the scheduled defragmentation).
--shellex
This option forces to list objects to be processed and display a prompt to hit any key after a job completion. It is intended for use in Explorer's context menu handler.

Volume letter:

  • Specifying just the volume letter will cause UltraDefrag to defragment the volume.
  • It is possible to specify multiple volume letters. Like this: udefrag c: d: x:
  • Also the following keys can be used instead of the volume letter:
    --all
    Process all available volumes.
    --all-fixed
    Process all volumes except removable.
    Note that --all-fixed key has higher precedence, if both keys are specified UltraDefrag will process fixed drives only.

Path:

  • Specifying a path will cause UltraDefrag to defragment only the specified path.
  • It is possible to specify multiple paths separated by spaces.
  • Paths including spaces must be enclosed by double quotes (").
  • Relative and absolute paths are supported. Example: udefrag "\%USERPROFILE\%" ..\Test "\My Documents" C:\WINDOWS\WindowsUpdate.log
  • Short paths (like C:\PROGRA~1\SOMEFI~1.TXT) aren't accepted on NT4.

Environment variables

UD_IN_FILTER
List of files to be included in defragmentation process. File names must be separated by semicolons.
UD_EX_FILTER
List of files to be excluded from defragmentation process. File names must be separated by semicolons.
UD_SIZELIMIT
Exclude all files larger than the specified size. The following size suffixes are accepted: Kb, Mb, Gb, Tb, Pb, Eb.
UD_FRAGMENTS_THRESHOLD
Exclude all files which have less fragments than the specified number.
UD_TIME_LIMIT
When the specified time interval elapses the job will be terminated automatically. The following time format is accepted: Ay Bd Ch Dm Es. Here A,B,C,D,E represent any integer number, y,d,h,m,s - suffixes represent years, days, hours, minutes and seconds.
UD_REFRESH_INTERVAL
Progress refresh interval, in milliseconds. The default value is 100.
UD_DISABLE_REPORTS
If this environment variable is set to 1 (one), no file fragmentation report will be generated.
UD_DBGPRINT_LEVEL
Control amount of the debugging output. NORMAL is used by default, DETAILED may be used to collect information for the bug report, PARANOID turns on a really huge amount of debugging information.
UD_LOG_FILE_PATH
If this variable is set, it should contain the path (including filename) to the log file to save debugging output into. If the variable is not set, no logging to the file will be performed.
UD_DRY_RUN
If this environment variable is set to 1 (one) the files are not physically moved. This allows testing the algorithm without changing the content of the volume.

Note that all filters are case insensitive. Each filter substring represents a pattern, UltraDefrag will search for it in paths. For example, the "temp;tmp" filter will be applied both to temporary folders and to Internet Explorer's cache.

Note that files excluded by filters are always shown as not fragmented on the cluster map. Because trash is unimportant anyway and it should not take our attention.

Example batch scripts

The following example illustrates defragmentation of a few different volumes in series adjusting parameters separately for each volume.

 @echo off

 set UD_EX_FILTER=system volume information;temp;recycle;.zip;.7z;.rar
 set UD_SIZELIMIT=50Mb
 udefrag c: > c:\ud.log

 set UD_IN_FILTER=My Documents
 udefrag d: >> c:\ud.log

 set UD_IN_FILTER=
 udefrag e: >> c:\ud.log

Notice that we are excluding archives in the script above. Because they are usually rarely accessed and may be left fragmented therefore without noticeable system performance degradation.

The next example demonstrates how the complex disk defragmentation job may be automated easily.

 @echo off

 rem Defragment small files.

 set UD_SIZELIMIT=50Mb
 udefrag c:

 rem Defragment large files 
 rem which have at least 5 fragments.

 set UD_SIZELIMIT=
 set UD_FRAGMENTS_THRESHOLD=5
 udefrag c:

The following three commands are very useful in disk defragmentation scripts too:

  • chkdsk checks volumes for errors and corrects them
  • shutdown -s -t 00 automatically shuts down the computer
  • hibernate4win now hibernates the computer

The last command is included in the UltraDefrag package. It was especially created to hibernate the computer through the command line after a disk defragmentation, which may take some time to finish.

Explorer's context menu handler

The UltraDefrag command line tool is also used as an Explorer's context menu handler. When you right click a drive, folder or file icon in Explorer, you can select an appropriate menu item to defragment the selected object.

To stop the defragmentation press Ctrl+C keys 4 times or close the command prompt.

Currently the context menu handler is not available in the portable version of the program.


Previous: Installation Next: Scheduled Defragmentation