How to reorder the files of a FAT32 file system?

I know this sounds a bit strange, but for some reasons, my car audio system is displaying the folders in the order it has been copied. There is no setting in the system to display the folders in an alphabetical order. This is really annoying as I have about 30GB of music which means a lot of folders and every time I add a new folder, it will be added at the end of the list... Also it is not practical at all when you want to search for something particular.

So I guess the system is reading the files in the order it has been recorded in the FAT32 record table. So the question is simple. Is there a way to reorder this record in an alphabetical order?


I have not tried this, but a google search lead to a result which seems almost perfect here. FAT-32 Sorter. It even describes pretty much exactly the problem you are having. I hope this helps.


It's not strange. Sorting the list requires "a lot" of memory, which may not be available on small embedded systems like MP3 players. You need a big enough array to store all the filenames before sorting them.

Therefore those systems just list the files in whatever order the directory entry stores its child items and remove the need for the array, since now you just load a single filename instead of the full directory listing.

You can manually sort the files by moving them to another directory in the order you want

If the storage medium is a FAT-formatted USB thumb drive, then the files will be enumerated in a complex order based on the order in which files are created and deleted and the lengths of their names. But the easy way out is simply to remove all the files from a directory then move file files into the directory in the order you want them enumerated. That way, the first available slot is the one at the end of the directory, so the file entry gets appended.

What order does the DIR command arrange files if no sort order is specified?

Or just use the tools made for this sorting purpose

  • mp3DirSorter
  • YAFS: Yet Another FAT Sorter
  • FAT Reader
  • FAT-32 Sorter
  • FAT Sorter
  • Sort MP3 Files On MP3 Player
  • https://github.com/maxpat78/FATtools

Another option that avoids the need for specific utility and allows you to set the sequence in any order you want, is to simply rename the files or folders on the FAT32 drive.

I have a USB flash drive I use in my car audio system (which plays files and folders in the order found on the drive) and I use this technique to set the order of the folders and thus the order that the audio system sees them.

My observation is that if a file or folder is renamed to a longer name, the directory entry is recreated at the end of the directory, and so would then appear to be last in the playing order. I can then rename it back to its original name and it will keep its new position. I then repeat this process with each folder or file until they are in the order I want. Start with the item you want second, then the item you want third and so on.

To make this process a bit less tedious, as small batch file can be used:

ren %1 %1-padding
ren %1-padding %1
dir