Use FATSORT to sort mp3 files & folders alphabetically

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
r__hughes
Posts: 359
Joined: Thu 13 Apr 2006, 04:14
Location: Montreal, Canada

Use FATSORT to sort mp3 files & folders alphabetically

#1 Post by r__hughes »

How to copy files/folders to a mp3 player alphabetically

My mp3 player has 2G base FAT32 memory & takes an additional FAT16 or FAT32 SD memory card.

It can handle folders, subfolders and sub-subfolders and keep all their files grouped properly - it also remembers the place in a file where it is stopped.

Just the thing I thought for audio-books where the files can be split into convenient 20-min segments.

But it will only play mp3 files in the order they were written to the memory card(s) - it doesn't read playlists & the onboard op-system can't sort filenames or folder names.

This puts me at the mercy of the copy algorithms used by the operating systems since I need the book chapters in the right order.

Puppy Linux can only do an alphabetic copy within folders by use of the 'select-all' icon in the top toolbar and a drag/drop to the target folder - this gets tedious and multi folder alphabetic copies don't work.

The solution is FATSORT - this is a command-line program that alphabetically sorts the FAT16/FAT32 name table of a memory card in a matter of seconds no matter what order you copied the files or folders!!!

I downloaded the (25K) fatsort-0.9.10-187.tar.gz from http://fatsort.berlios.de/
extracted it to / then compiled & installed as per included instructions. Fatsort installed to /usr/local/sbin which is not in the PATH declaration so I made a symlink to access it from /usr/sbin which is in the PATH

I can report that it works excellently on my frugal puppy411

The helpfile gives the following options:-
-------------------------------------------------
Usage: fatsort [options] device

Options:
-c Ignore case of file names
-f Force sorting even if filesystem is mounted
-h Print some help
-i Print file system information only
-l Print current order of files only
-o flag Sort order of files where flag is one of
d : directories first (default)
f : files first
a : files and directories are not differentiated
-n Natural order sorting
-d dir Sort directory dir only
-D dir Sort directory dir and all subdirectories
-q Be quiet
-r Sort in reverse order
-v Print version information

Device must be a FAT16 or FAT32 file system. FAT12 is not supported yet.

Example: fatsort /dev/sda
-----------------------------------------------------

Fatsort normally only works on unmounted devices.

FATSort Utility 0.9.10 by Boris Leidner <fatsort(at)formenos.de>
Attachments
fatsort-0.9.10-187.tar.gz
This version of fatsort available 16MAY09
(24.94 KiB) Downloaded 746 times
--- quad booting Slacko57NPAE, Slacko56NPAE, Slacko55PAE (with OO4, devx, Gimp) & WXP on DELL Dimension 2400 PC & DELL Latitude 630 Laptop using grub.
---USB-Flash booting same on Samsung N110 WXP Netbook and Lenovo q100 WXP netPC.

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#2 Post by Flash »

When I first tried to use Puppy to load an audio book into my mp3 player I found that ROX loaded the mp3 files in some random order, which is the order the mp3 player played them. I discovered that if I open in ROX the folder containing the mp3 files I want to transfer to the mp3 player, ctrl-a to Select all the mp3 files then click 12 times the Change sort criteria icon at the top of the ROX window, when I drag the mp3 files to the mp3 player (which I also open With ROX) they will load in alphabetical (or numerical) order. :shock:

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#3 Post by zigbert »

Just to mention that Pmusic can copy files in the playlist to your mp3 player, and number the copied files to keep sort order on your mp3-player.

r__hughes
Posts: 359
Joined: Thu 13 Apr 2006, 04:14
Location: Montreal, Canada

#4 Post by r__hughes »

Thanks for all your comments - it seems that we have all experienced the same sort of copy problem.

Fatsort deals with my particular problem since my mp3 audiobooks are stored in the following manner

author folder -- eg A_Christie
series folder --- eg H_Poirot, M_Marples
book folder --- eg Murder_is_Announced
mp3 files --- eg 01_Murder_is_Announced etc etc

I sometimes copy all my A_Christie to the same SD card as another author eg B_Bova (Mars & Return_to_Mars). I copy all the nested folders as appropriate.

Fatsort arranges everything in the correct Author, Series, Book, mp3 file
order. (Previously I had to create each individaual folder/subfolder manually in the order I wanted then go back and populate each folder individually using the 'select-all' / drag'n'drop method. This could take over an hour with a full 2G SD card. Now with Fatsort I can bulk copy the nested folders in 10mins (with USB2) + 10sec for sorting.
:) :) :)
--- quad booting Slacko57NPAE, Slacko56NPAE, Slacko55PAE (with OO4, devx, Gimp) & WXP on DELL Dimension 2400 PC & DELL Latitude 630 Laptop using grub.
---USB-Flash booting same on Samsung N110 WXP Netbook and Lenovo q100 WXP netPC.

User avatar
Monsie
Posts: 631
Joined: Thu 01 Dec 2011, 07:37
Location: Kamloops BC Canada

Use FATSORT to sort mp3 files & folders alphabetically

#5 Post by Monsie »

Update:

Following a discussion in this thread over here about copying multiple files from one place to another in some sort of order, I came across FATSort as one of the possible solutions for this scenario.
DESCRIPTION
FATsort sorts directory structures of FAT filesystems. Many MP3 hardware players don't sort files automatically but play them in the order they were transmitted to the device. FATSort can help here.
FATSort was last updated to V. 0.9.17 as of April, 2012 so I made a new package. I removed the /local directory in the source code, so it (FatSort) will be found in the regular location. Although this is a Pet it is a command line based utility only, for example:

Code: Select all

fatsort -option path/to/device #or specifically
fatsort -c /dev/sdc1
The option above ignores the case of the letters in the filenames when sorting.

For specific help using FATSort, type:

Code: Select all

man fatsort
at the terminal.

I compiled FATSort in Wary 5.3 but I expect it will work with any breed of Puppy. While this utility appears to have installed properly with no errors, I was not able to test it with an old mp3 player of mine... apparently because it's been sitting and gathering dust for a long time and needs a recharge... so for those who want to test this utility, your feedback on how well it works is welcome.

Monsie
Attachments
fatsort-0.9.17.269-i486.pet
(14.67 KiB) Downloaded 744 times
My [u]username[/u] is pronounced: "mun-see". Derived from my surname, it was my nickname throughout high school.

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#6 Post by Flash »

I'm not clear on how Fatsort works. Does it first copy the stuff over to the mp3 player, then sort everything properly, or does it just create the proper directory structure in the mp3 player, then copy all the files into the correct place and in the correct order, more or less the way rsync -a seems to do?

r__hughes
Posts: 359
Joined: Thu 13 Apr 2006, 04:14
Location: Montreal, Canada

#7 Post by r__hughes »

Fatsort doesn't copy anything - it sorts the File Allocation Table (FAT) of the requested device partition. It is assumed that the user has already named the directory/subdirectory/filenames in alphabetic order and that the operating system has copied the files to the mp3 device partition in some arbitrary order which results in a non-sequential playback order.

After Fatsort the operating system sees (via FAT) all directories and included subdirectories/files in the selected partition in alphabetic order but the original files are not moved in any way.

A non-intelligent mp3 player which relies on operating system access now plays music files or book chapter files in correct alphabetical order of directory/subdirectories/filename.
--- quad booting Slacko57NPAE, Slacko56NPAE, Slacko55PAE (with OO4, devx, Gimp) & WXP on DELL Dimension 2400 PC & DELL Latitude 630 Laptop using grub.
---USB-Flash booting same on Samsung N110 WXP Netbook and Lenovo q100 WXP netPC.

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#8 Post by Flash »

So Fatsort doesn't copy anything at all, it just sorts the files and directories in the mp3 player after they've been copied to it by another program such as cp or rsync?

User avatar
Monsie
Posts: 631
Joined: Thu 01 Dec 2011, 07:37
Location: Kamloops BC Canada

Use FATSORT to sort mp3 files & folders alphabetically

#9 Post by Monsie »

Flash wrote:So Fatsort doesn't copy anything at all, it just sorts the files and directories in the mp3 player after they've been copied to it by another program such as cp or rsync?
Flash, that's basically it. From what I have read, (and you probably know more about this than me) many mp3 players --especially the older ones-- are not able to store the music in any alphabetical or numerical order. Apparently, this is a limitation of FAT in that it reads the files in the order that it finds them. The fact that we can see files in order on a flash drive that is formatted either FAT16/32 is a function of the operating system which does the sorting for us. From further reading, some newer mp3 players can store the files in any given order, and I believe that others can store files alphabetically after a firmware update.

So, it turns out that there are such utilities for Windows users also, including a program with a gui called FATSort found here that was written by someone else... not the same person who wrote FATSort over here for Linux based systems :?

I was not able to test FATSort on my mp3 player, as it seems to have bit the dust... However, I copied about 16 mp3 files to one of my FAT16 formatted flash drives, put them into a random order, and FATSort re-arranged the files alphabetically.

In further testing, I used another FAT16 formatted flash drive that had an assortment of files of all kinds, and I found that FATSort corrupted some of the files :( So, even though some of the info at http://sourceforge.net/projects/fatsort/ seems to indicate this utility will sort any kind of file on a FAT formatted storage device, I did not find this to be the case... Furthermore, the developer indicated that he wrote this program especially for mp3 players. Therefore, I recommend only using FATSort for audio type files on a media player and if in doubt, be sure to have those files backed up.

Hope this clarifies things a bit,
Monsie
My [u]username[/u] is pronounced: "mun-see". Derived from my surname, it was my nickname throughout high school.

User avatar
chrome307
Posts: 708
Joined: Thu 15 Jan 2009, 11:00

#10 Post by chrome307 »

Attached pet for Lucid 528-005
Attachments
fatsort-0.9.17.269-i686.pet
(14.71 KiB) Downloaded 678 times

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#11 Post by Flash »

Monsie, thanks for the testing and the explanation. You more than answered my question about FATsort.

A typical case for me would be a folder containing 200 mp3 files of various sizes, but the size clusters around 1 MB. Copying the folder with the cp command or by dragging in ROX gives the same result. Cp copies them to my mp3 player in not exactly random order, but not strictly numerical order either. ROX seems to do the same, so perhaps it uses the cp command. I can force ROX to copy the files in strict numerical order, but the workaround is tedious and slow. Rsync -a seems to copy them in strictly numerical order. Today I'll be listening to the first book I copied with rsync, so pretty soon I'll know for sure if rsync -a did the trick. If it did, I won't need to use FATsort, but it's nice to know it's here if I do. :)

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#12 Post by Flash »

I installed the fatsort .pet in Precise Puppy. When I enter

Code: Select all

fatsort --help
in a console I get the list of options for fatsort. However, I get nothing but error messages of various kinds when I try to use fatsort on a directory full of mp3 files.

User avatar
Monsie
Posts: 631
Joined: Thu 01 Dec 2011, 07:37
Location: Kamloops BC Canada

Use FATSORT to sort mp3 files & folders alphabetically

#13 Post by Monsie »

Flash,

To get help with fatsort, in the terminal I can type either:

Code: Select all

fatsort -h
or

Code: Select all

man fatsort
The latter command brings up a html file in the browser which I find easier to read and to follow.

That said, I find the directions a bit confusing because it appears that you can reverse the order in fatsort when specifying either the options or the device... for example, to sort a selection of mp3 files while ignoring the file letter case (upper or lower) I can type:

Code: Select all

fatsort -c /dev/sdc
or

Code: Select all

fatsort /dev/sdc -c
and both commands appear to work. I do prefer the syntax of the first command.

Now I haven't been able to fully test fatsort, because I wasn't able to use my old mp3 player. Further, when testing fatsort with a flash drive, I can only infer that fatsort is working from the output at the terminal, and this is because fatsort will not work on a drive that is mounted, and also because the operating system compensates by displaying the files in alphabetical order whether they are in actual order on the device or not.

It would be helpful to know what options you are trying to use and what kind of errors you are getting...

Here is a screen-shot of fatsort at the command line.

Hope this helps,
Monsie
Attachments
fatsort.jpg
(13.72 KiB) Downloaded 1714 times
My [u]username[/u] is pronounced: "mun-see". Derived from my surname, it was my nickname throughout high school.

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#14 Post by Flash »

OK, I think I see what I did wrong. I tried to FATsort a single directory on a mp3 player rather than the whole drive. I'm afraid to run FATsort on the whole mp3 player for fear it will mess up the player's primitive operating system. :(

Also, from your screenshot, FATsort apparently runs without giving any idea whether it did anything, unlike running rsync with the -v option.

On the other hand, rsync -av copies directories of mp3 files very fast and in the correct order, so there's no need for FATsort. :)

Post Reply