[fatsort]

Black Hole

May contain traces of nut
Apropos this thread I would find this useful as a command line utility in the CF. Please can we have it as a package?

Package Namefatsort
FunctionRe-orders entries in the File Allocation Table (for FATx file systems)
PurposeConsumer devices (eg stand-alone MP3 players) accessing FATx file systems without OS support read files in the order they are indexed in the FAT without any sorting, which usually means the order in which files were added to the device. This can result in (eg) tracks playing out of order. fatsort provides various options to sort the order in which files and directories appear within the FAT.

The user can enforce any arbitrary sort order by prefixing filenames with a sort key (eg 001, 002, 003...) then running fatsort, and then (optionally) renaming the files to remove the sort key.
man pagehttps://fatsort.sourceforge.io/fatsort.1.html
Source Codehttps://github.com/dchaid/fatsort
https://sourceforge.net/projects/fatsort/files/
 
Last edited:
That's old source code on github. The sourceforge version is up to date. Neither build straightforwardly of course and fail in different ways (oh the joy).
I've packaged the latter (1.6.5 rather than 1.5.0) and it's in the Beta repository.
Work on a copy of your media, not the original! Let me know what happens.
 
Meh.

It seems my car stereo is listing tracks in alphanumeric order based on short file name (maybe). I tried suffixing an out-of-order sort key, and even without applying fatsort the stereo followed my alterations!

How can I go about looking at the actual order of entries in the FAT? busybox ls seems to sort whether you like it or not.
 
Yes I did. Which of these relates to "unsorted"?

Code:
BusyBox v1.20.2 (2013-01-02 19:13:09 GMT) multi-call binary.                                       
                                                                                                  
Usage: ls [-1AaCxdLHRFplinsehrSXvctu] [-w WIDTH] [FILE]...                                         
                                                                                                  
List directory contents                                                                           
                                                                                                  
        -1      One column output                                                                 
        -a      Include entries which start with .                                                 
        -A      Like -a, but exclude . and ..                                                     
        -C      List by columns                                                                   
        -x      List by lines                                                                     
        -d      List directory entries instead of contents                                         
        -L      Follow symlinks                                                                   
        -H      Follow symlinks on command line                                                   
        -R      Recurse                                                                           
        -p      Append / to dir entries                                                           
        -F      Append indicator (one of */=@|) to entries                                         
        -l      Long listing format                                                               
        -i      List inode numbers                                                                 
        -n      List numeric UIDs and GIDs instead of names                                       
        -s      List allocated blocks                                                             
        -e      List full date and time                                                           
        -h      List sizes in human readable format (1K 243M 2G)                                   
        -r      Sort in reverse order                                                             
        -S      Sort by size                                                                       
        -X      Sort by extension                                                                 
        -v      Sort by version                                                                   
        -c      With -l: sort by ctime                                                             
        -t      With -l: sort by mtime                                                             
        -u      With -l: sort by atime                                                             
        -w N    Assume the terminal is N columns wide                                             
        --color[={always,never,auto}]   Control coloring
 
Ah - it may be because I have installed bash, so I get
Code:
#ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort.

Mandatory arguments to long options are mandatory for short options too.
  -a, --all                  do not ignore entries starting with .
  -A, --almost-all           do not list implied . and ..
      --author               with -l, print the author of each file
  -b, --escape               print C-style escapes for nongraphic characters
      --block-size=SIZE      scale sizes by SIZE before printing them.  E.g.,
                               `--block-size=M' prints sizes in units of
                               1,048,576 bytes.  See SIZE format below.
  -B, --ignore-backups       do not list implied entries ending with ~
  -c                         with -lt: sort by, and show, ctime (time of last
                               modification of file status information)
                               with -l: show ctime and sort by name
                               otherwise: sort by ctime
  -C                         list entries by columns
      --color[=WHEN]         colorize the output.  WHEN defaults to `always'
                               or can be `never' or `auto'.  More info below
  -d, --directory            list directory entries instead of contents,
                               and do not dereference symbolic links
  -D, --dired                generate output designed for Emacs' dired mode
  -f                         do not sort, enable -aU, disable -ls --color
  -F, --classify             append indicator (one of */=>@|) to entries
      --file-type            likewise, except do not append `*'
      --format=WORD          across -x, commas -m, horizontal -x, long -l,
                               single-column -1, verbose -l, vertical -C
      --full-time            like -l --time-style=full-iso
  -g                         like -l, but do not list owner
      --group-directories-first
                             group directories before files.
                               augment with a --sort option, but any
                               use of --sort=none (-U) disables grouping
  -G, --no-group             in a long listing, don't print group names
  -h, --human-readable       with -l, print sizes in human readable format
                               (e.g., 1K 234M 2G)
      --si                   likewise, but use powers of 1000 not 1024
  -H, --dereference-command-line
                             follow symbolic links listed on the command line
      --dereference-command-line-symlink-to-dir
                             follow each command line symbolic link
                             that points to a directory
      --hide=PATTERN         do not list implied entries matching shell PATTERN
                               (overridden by -a or -A)
      --indicator-style=WORD  append indicator with style WORD to entry names:
                               none (default), slash (-p),
                               file-type (--file-type), classify (-F)
  -i, --inode                print the index number of each file
  -I, --ignore=PATTERN       do not list implied entries matching shell PATTERN
  -k                         like --block-size=1K
  -l                         use a long listing format
  -L, --dereference          when showing file information for a symbolic
                               link, show information for the file the link
                               references rather than for the link itself
  -m                         fill width with a comma separated list of entries
  -n, --numeric-uid-gid      like -l, but list numeric user and group IDs
  -N, --literal              print raw entry names (don't treat e.g. control
                               characters specially)
  -o                         like -l, but do not list group information
  -p, --indicator-style=slash
                             append / indicator to directories
  -q, --hide-control-chars   print ? instead of non graphic characters
      --show-control-chars   show non graphic characters as-is (default
                             unless program is `ls' and output is a terminal)
  -Q, --quote-name           enclose entry names in double quotes
      --quoting-style=WORD   use quoting style WORD for entry names:
                               literal, locale, shell, shell-always, c, escape
  -r, --reverse              reverse order while sorting
  -R, --recursive            list subdirectories recursively
  -s, --size                 print the allocated size of each file, in blocks
  -S                         sort by file size
      --sort=WORD            sort by WORD instead of name: none -U,
                             extension -X, size -S, time -t, version -v
      --time=WORD            with -l, show time as WORD instead of modification
                             time: atime -u, access -u, use -u, ctime -c,
                             or status -c; use specified time as sort key
                             if --sort=time
      --time-style=STYLE     with -l, show times using style STYLE:
                             full-iso, long-iso, iso, locale, +FORMAT.
                             FORMAT is interpreted like `date'; if FORMAT is
                             FORMAT1<newline>FORMAT2, FORMAT1 applies to
                             non-recent files and FORMAT2 to recent files;
                             if STYLE is prefixed with `posix-', STYLE
                             takes effect only outside the POSIX locale
  -t                         sort by modification time
  -T, --tabsize=COLS         assume tab stops at each COLS instead of 8
  -u                         with -lt: sort by, and show, access time
                               with -l: show access time and sort by name
                               otherwise: sort by access time
  -U                         do not sort; list entries in directory order
  -v                         natural sort of (version) numbers within text
  -w, --width=COLS           assume screen width instead of current value
  -x                         list entries by lines instead of by columns
  -X                         sort alphabetically by entry extension
  -Z, --context              print any SELinux security context of each file
  -1                         list one file per line
      --help     display this help and exit
      --version  output version information and exit

SIZE may be (or may be an integer optionally followed by) one of following:
KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.

Using color to distinguish file types is disabled both by default and
with --color=never.  With --color=auto, ls emits color codes only when
standard output is connected to a terminal.  The LS_COLORS environment
variable can change the settings.  Use the dircolors command to set it.

Exit status:
 0  if OK,
 1  if minor problems (e.g., cannot access subdirectory),
 2  if serious trouble (e.g., cannot access command-line argument).

Report ls bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
Report ls translation bugs to <http://translationproject.org/team/>
For complete documentation, run: info coreutils 'ls invocation'

That reminds me, I use a Linux pc so that I can use GUI to check or modify mp3 tags, transfer to device then fatsort against the device
 
Last edited:
I've installed bash, and I've even rebooted, but I'm still getting the Busybox version of ls. What do I do? Remove Busybox??
 
Just install coreutils (the help for ls on my humax hints to it - but I didn't notice earlier)
To be honest I can't remember the exact packages I installed manually so here is a list
opkg list-installed
7zip - 9.20.1
abduco - 0.6-1
anacron - 2.3-2
at - 3.1.18
auto-schedule-restore - 1.3
auto-unprotect - 2.0.2
badnts - 1.0.1-1
bash - 4.3-30
betaftpd - 0.0.8pre17-5
binutils - 2.21-1
boot-settings - 1.0.5
bsed - 1.0.0
busybox - 1.20.2-1
bzip2 - 1.0.4
ca-bundle - 3.41
chaseget - 0.1.2-1
cifs - 2.6.18
coreutils - 8.11
cpulimit - 0.1.1-0
crashdiag - 1.1
cron-daemon - 1.18.3-5
curl - 7.63.0
curl-command - 7.21.2
dbupdate - 1.0.0
detectads - 0.2.5-4
disable-dso - 0.3-1
disable-ota - 1.0.3-4
dlna-servername - 1.0.3
dropbear-ssh - 2018.76-1
e2fsprogs - 1.42.13
epg - 1.2.8
epgpatch - 1.0.3
exfat - 1.2.6
fan - 1.0.0
ffmpeg - 4.1-1
file - 5.0.4
fix-disk - 0.5
forcedate - 1.1
fuse - 2.7.6-1
gawk - 3.1.8
gcc - 4.5.2-3
gdb - 7.1-1
gmake - 3.82
header-files - 1.9
hmt - 2.0.11
hrwconv - 0.0.2
hwctl - 1.0.0
id3v2 - 0.1.11-1
inotify-tools - 3.14
iplfix - 1.0
ir - 1.23
jim - 0.82-2
jim-cgi - 0.7-2
jim-xconv - 1.0.1
lamemp3 - 3.98.4
libgmp - 5.0.1
libiconv - 1.13.1-1
libmpc - 0.8.2
libmpfr - 3.0.0
libparted - 3.1
libpcre - 8.37-1
libreadline - 6.2-1
libsndfile - 1.0.25-2
libutil - 0.9.29
libxconv - 1.0.4
lighttpd - 1.4.53-2
lsof - 4.87
multienv - 1.7-1
ncurses - 5.9
network-shares-automount - 1.4-2
nfs-utils - 1.2.3-2
nicesplice - 1.8
nicesplice-magic-folders - 1.2
ntfs-3g - 2013.1.13-5
ntfsprogs - 2013.1.13-1
ntpclient - 2010-365-5
nugget - 1.0
openssl - 1.1.1.d-1
openssl-command - 1.0.0.d
parted - 3.1-1
portmap - 6.0-1
procps - 3.2.8-3
python - 2.7.1-3
qtube - 0.1.0-1
recmon - 2.2.1-2
rsvsync - 1.1.13
rsync - 3.0.8
samba - 2.2.12-6
service-control - 2.5
sidecar - 2.8
smartmontools - 6.4
sqlite3 - 3.41.1-2
ssmtp - 2.64
stripts - 1.4.6-1
swapper - 1.0.1
sysmon - 1.2.6
tcpfix - 1.0.0
tcpping - 1.1
tempmon - 1.0.2
tmenu - 1.24
trm - 1.2
tweak - 1.0
uclibc-devel - 0.9.31-2
undelete - 1.6-8
vim - 7.3-1
virtual-disk2 - 2.0-5
webif - 1.5.2-1
webif-channelicons - 1.1.30
webif-charts - 1.3
webshell - 1.0.4
wget - 1.20.3
wireless-helper - 2.0
wireless-tools - 29-1
wpa-supplicant - 0.6.10
youtube-dl - 2023.07.05
zip - 3.0-1[/spolier]
 
That's better! And the raw directory is not sorted so that confirms the player is sorting.
 
So is there any point in putting it in the main repository? Although the work has already been done so it seems a shame...
 
Back
Top