phatsort: FAT filesystem sort utility

[ library, mit, program, utils ] [ Propose Tags ]

This package provides a utility for sorting files and directories on a FAT filesystem. Please see the README on GitHub at

[Skip to Readme]


Automatic Flags

Use optparse-applicative 0.18 or newer


Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],
Change log
Dependencies ansi-wl-pprint (>=0.6.8 && <1.1), base (>=4.10.1 && <4.20), directory (>= && <1.4), filepath (>= && <1.5), MonadRandom (>=0.5 && <0.7), optparse-applicative (>=0.13 && <0.19), phatsort, prettyprinter (>=1.7.1 && <1.8), random-shuffle (>=0.0.4 && <0.1), transformers (>=0.5 && <0.7), unix-compat (>=0.5 && <0.8) [details]
License MIT
Copyright Copyright (c) 2019-2023 Travis Cardwell
Author Travis Cardwell <>
Maintainer Travis Cardwell <>
Revised Revision 3 made by TravisCardwell at 2023-12-04T20:22:12Z
Category Utils
Home page
Bug tracker
Source repo head: git clone
Uploaded by TravisCardwell at 2023-05-28T02:04:45Z
Distributions LTSHaskell:, NixOS:, Stackage:
Executables seqcp, phatsort
Downloads 250 total (10 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for phatsort-

[back to package description]


Project Status: Active – The project has reached a stable, usable state and is being actively developed. GitHub CI Hackage Stackage LTS Stackage Nightly


The PhatSort project provides two command-line utilities for sorting files and directories on FAT filesystems. The phatsort utility sorts files and directories that are already on the filesystem. The seqcp utility copies files and directories to the filesystem in sorted order.

There are many MP3 players that allow you to mount the device as external storage and manage the media yourself. The storage generally uses a FAT filesystem. When copying multiple files onto the storage, using the command line (cp/mv) or a GUI, they are generally stored in an arbitrary order. This is not a problem if the firmware of the MP3 player sorts by filename, but many MP3 players use the order in the FAT filesystem without sorting, which results in podcasts and album tracks being played out of order.

There are some utilities that sort the FAT tables of an unmounted filesystem. (See Related Software for information and links.) Unfortunately, there are many devices for which this does not work. PhatSort takes a different approach to solving the problem. It works by creating new directories and moving ("renaming") the files in the desired order, while the filesystem is mounted. This method works on all devices that have been tried so far.

PhatSort also (optionally) forces the filesystem buffers to be written to the storage media after each change. This helps avoid write failures when using devices that have problems with writing large amounts of data. Note that the seqcp utility helps with this issue even on non-FAT filesystems.



PhatSort has only been tested on Linux. It might work on other operating systems. Scripts that are output use POSIX shell commands and therefore require a POSIX shell to execute.


.deb Package Installation

Check the Releases page for .deb packages.

.rpm Package Installation

Check the Releases page for .rpm packages.

Installation From Hackage

Install PhatSort from Hackage using Cabal as follows:

$ cabal v2-install phatsort

Installation From Stackage

Install PhatSort from Stackage using Stack as follows:

$ stack install phatsort


See the phatsort and seqcp man pages for usage information.

FATSort is a command-line utility that sorts unmounted FAT filesystems by direct manipulation of the FAT tables. Unfortunately, there are many devices for which this does not work.

YAFS is a command-line utility that sorts unmounted FAT filesystems by direct manipulation of the FAT tables. Visual YAFS provides a GUI. I have not tried either of these.

DriveSort is Windows GUI software that sorts unmounted FAT filesystems by direct manipulation of the FAT tables. I have not tried it.



The main branch is reserved for releases. It may be considered stable, and HEAD is always the latest release.

The develop branch is the primary development branch. It contains changes that have not yet been released, and it is not necessarily stable.

Hackage revisions are made for metadata changes, such as relaxation of constraints when new versions of dependencies are released. The phatsort.cabal metadata in the main branch may therefore not match that of Hackage. The phatsort.cabal metadata in the develop branch may match, unless work is being done on a new release that contains other changes.


All releases are tagged in the main branch. Release tags are signed using the GPG key.


Issues and feature requests are tracked on GitHub:

Issues may also be submitted via email to


This project is released under the MIT License as specified in the LICENSE file.