Scroll to navigation

FATSORT(1) User Commands FATSORT(1)

NAME

fatsort - FAT file system sorting utility

SYNOPSIS

fatsort [OPTIONS] DEVICE

DESCRIPTION

FATSort sorts the directory structure of FAT file systems, including FAT12, FAT16, FAT32, and exFAT.

Sort options:

Use ASCII order for sorting.
Ignore case of file names (default for most locales).
Ignore the prefix PFX when comparing file names.
Use natural order sorting.

-o FLAG Set the sort order of files, where FLAG is one of:

d : directories first (default)
f : files first
a : do not distinguish between files and directories
Sort in reverse order.
Sort in random order.
This option overrides all other sort options.
Sort by last modification date and time.

The following options can be specified multiple times to control which directories are sorted:

Sort the specified directory DIR only.
Sort DIR and all its subdirectories.
Exclude DIR from sorting.
Exclude DIR and all its subdirectories from sorting.

The following options can be specified multiple times to select directories using POSIX.2 extended regular expressions:

Only sort directories matching regular expression RE.
Don't sort directories matching regular expression RE.

Note: Options -e and -E cannot be used together with -d, -D, -x and -X.

Use the specified locale LOC instead of the system locale. FATSort follows locale-specific rules when sorting file names and directories.

More options:

List the current file order only.
Display file system information only.
Force sorting even if the file system is mounted.

-h, --help

Display this help message.

-v, --version

Show version information.
Suppress all non-error output.

DEVICE must be a FAT12, FAT16, FAT32 or exFAT file system.

WARNING: THE FILE SYSTEM MUST BE CONSISTENT (I.E., FREE OF ERRORS) BEFORE RUNNING FATSORT. THERE IS A RISK OF FILE SYSTEM CORRUPTION. ALWAYS BACK UP YOUR DATA.

ENVIRONMENT

The environment variable LC_ALL determines the system locale used by FATSort.

EXAMPLES

Sort /dev/sda.
Sort /dev/sdb1 using natural order.

AUTHOR

Written by Boris Leidner.

REPORTING BUGS

Report bugs to <fatsort@formenos.de>.

COPYRIGHT

Copyright © 2004-2025 Boris Leidner. License GPLv2: GNU GPL version 2 (see LICENSE.txt)
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

November 2025 fatsort 1.7