Console interface
Prev
Next

Chapter 3. Console interface

Table of Contents

Overview
Command line switches
Accepted environment variables
Context menu handler
Example batch scripts

Overview

The console application is called udefrag.exe. It is placed in system32 directory by the installer. Therefore you can call it from the command line or run box without specifying the full path. The program accepts a lot of useful options: you can perform any disk defragmentation job using this tool.

Command line switches

Usage:

udefrag [command] [options] [volumeletter:]

Commands
-a, --analyze Analyze specified volume only.
--defragment Defragment volume. This key is optional - if no command is specified udefrag will defragment volume.
-o, --optimize Optimize volume space by moving all files to the begining of the drive.
-l, --list-available-volumes List volumes available for defragmentation, except removable media. Each line of output contains volume letter, type of file system, total size and percent of free space.
-la, --list-available-volumes=all List all available volumes.
-h, -?, --help Show help screen. Running udefrag without arguments have the same effect.
Options
-b, --use-system-color-scheme Use system (usually black/white) scheme instead of green color.
-p, --suppress-progress-indicator Hide progress indicator.
-v, --show-volume-information Show volume information after a job.
-m, --show-cluster-map Show map representing clusters on specified volume.
--map-border-color=color Specify 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 You can specify map symbol here. There are two supported formats: you can type symbol directly or specify its number in hexadecimal form. Like this: --map-symbol=0x1 :-) Valid numbers are in range: 0x1 - 0xFF '%' symbol is used by default.
--map-rows=n Number of rows in cluster map. Default value is 10.
--map-symbols-per-line=n Number of map symbols containing in each row of map. Default value is 68.

Specifying just the drive letter will cause UltraDefrag to defragment the drive. If you abort the operation with Ctrl+C or close the shell window, UltraDefrag will exit safely without destroying any data.

Examples

I. Console application after a successful analyze run:
Command prompt
Microsoft Windows XP [5.1.2600] (C) Microsoft Corporation, 1985-2001. C:\>udefrag -a c:
UltraDefrag v3.2.0, Copyright (c) Dmitri Arkhangelski, 2007-2009. UltraDefrag comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. c: analyse: 100% complete, fragmented/total = 916/16298
C:\>_
II. udefrag -l command in action:
Command prompt
Microsoft Windows XP [5.1.2600] (C) Microsoft Corporation, 1985-2001. C:\>udefrag -l
UltraDefrag v3.2.0, Copyright (c) Dmitri Arkhangelski, 2007-2009. UltraDefrag comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.
Volumes available for defragmentation: C: NTFS 3.92 Gb 6 % D: NTFS 9.42 Gb 3 % E: FAT32 59.30 Gb 5 %
C:\>_
III. Cluster map customization example:

Note that files excluded by filters are treated here always as unfragmented. Because trash is unimportant anyway and it should not take an attention.

Accepted environment variables

To set defragmenter options you should use the Environment Variables. To set each of them you can simply type in command line set VarName=Value where VarName is a name of the environment variable and Value is a string to be assigned to the specified variable. The good practice is to store such commands in a batch script before udefrag.exe calls. That will save a lot of your time. This practice will be discussed below. Here is a list of defragmentation related environment variables with a full explaination:

Environment variables
UD_IN_FILTER List of files to be included in defragmentation process. File names must be separated by semicolon. Like this: set UD_IN_FILTER=My Documents. After this assignment the defragger will process My Documents directory contents only. The default value is an empty string that means: all files will be included.
UD_EX_FILTER List of files to be excluded from defragmentation process. File names must be separated by semicolon. Like this: set UD_EX_FILTER=system volume information;temp;recycler. After this assignment many temporary files will be excluded from the defragmentation process. The default value is an empty string. It means: no files will be excluded.
UD_SIZELIMIT Ignore files larger than specified value. You can either specify size in bytes or use the following suffixes: Kb, Mb, Gb, Tb, Pb, Eb. P.a., use set UD_SIZELIMIT=10Mb to exclude all files greater than 10 megabytes. The default value is zero. It means: there is no size limit.
UD_FRAGMENTS_THRESHOLD Ignore files that have less number of fragments than specified by this parameter. The default value is zero. It means: there is no fragments threshold.
UD_TIME_LIMIT Specify the time limit for the defragmentation process. When specified interval elapses volume defragmentation/optimization job will be stopped. Time interval must be specified in the following form: Ay Bd Ch Dm Es. Here A,B,C,D,E represents any integer numbers; y,d,h,m,s suffixes are used for years, days, hours, minutes and seconds. Par example, 20 minutes 5 seconds will be represented as 20m 5s. The default value is an empty string which means: no time limit exists.
UD_REFRESH_INTERVAL Specify the progress indicator refresh interval in milliseconds. The default value is 500.
UD_DISABLE_REPORTS Set this parameter to 1 (one) to disable reports generation. The default value is 0.
UD_DBGPRINT_LEVEL This parameter can be in one of three states. Set UD_DBGPRINT_LEVEL=NORMAL to view useful messages about the analyse or defrag progress. Select DETAILED to create a bug report to send to the author when an error is encountered. Select PARANOID in extraordinary cases. Of course, you need have DbgView program or DbgPrint Logger installed to view logs. The default value is NORMAL.

Notes about filter:

Context menu handler

The console application is also used as a context menu handler. When you right click drive/folder/file icon in Explorer you can select [--- Ultra Defragmenter --] menu item to defragment the selected object.

To stop the defragmentation press Ctrl+C keys 4 times or close the console application window.

Currently this feature is not available in portable version of the program.

Example batch scripts

The best practice is to use the console application in batch scripts. You can define all program's options there and defragment multiple volumes in series by typing a single command. Here is the complete example. To try them store the code into ud-example.cmd file and click it's icon.

@echo off

set UD_EX_FILTER=system volume information;temp;recycler
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

The command set UD_IN_FILTER= destroys the specified variable. The appropriate option will have the default value after this command.

The following example demonstrates flexibility of filters which allow you to perform a very effective defragmentation:

@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:

Batch files are powerful enough, try to insert commands to play sounds after each defragmentation. If you doubt that your volumes are in good state then add chkdsk command too. Also you can use shutdown -s -t 00 command to halt your computer after the defragmentation job.

To hibernate your PC use hibernate4win now command. An appropriate tool is included in UltraDefrag package; it installs by default to your system32 directory.

Prev
Next
Home


ultradefrag.sourceforge.net