Car audio-player usb-drive: physically sorting mp3 files on usb-drive. Filemanagers sorting.

I used fatsort today so my car-stereo will play my mp3s in the expected order. Fatsort worked well.

I do not want to keep using fatsort, so I am looking for a file-manager that can move/copy files in tree-structures of folders, sorted as per the panel. Rather than just copying the files in the order they are on the disk. Does a file-manager with that capability exist?

As far as I knoww the linux move command "mv" does not have an option to sort and move.

On my usb-stick (32Gb stick with 20Gb of music for in the car) I tried first to create a folder "new" and then move all directories/sub-directories/files there in a sorted way. But that does not work. In the filemanagers I know even if the panel-view is sorted, if you copy a tree, it will just preserve the original order. Both the dir-command in a dos-box and using the "unsorted" view in Total Commander show that the mp3s were still in the same order.

Is there a file-manager that can move/copy directories/subdirectories/files in the order the panel-view is showing for the current directory?

Thanks,
Y.

The sort in which the files are played is up the mp3 player (in this case your car's). Some players sort the files by name and other read their metadata ad sort them by album or by title, for example. Other players let you choose a sorting method. First you need to figure out how the player sorts the files. The order in which the files are moved or copied has nothing to do with it.

Your best bet may be that the player sorts the files by filename, or at least lets choose that sorting method. In this case you can rename the files to begin with a number, sorted in the order you want. For example: 001-[name].mp3; 002-[name].mp3; etc.

To do this there are a bunch of tolls you can use, or you can even write a script to do it. I personally use krename.

1 Like

The fact that fatsort exists shows that many players will simply use the order on the drive.

Thanks for the time you took, but I want to find a file-manager that copies or moves all files/folders in a tree in the order that the panel is sorted in, rather than in the order they are on disk.

Well, I never used fatsort, but I did use A LOT of mp3 players and never saw one which played files in the order they were copied. It doesn't make sense because most filesystems don't write the files in a linear layer anyway! If you can't choose the folder to play, then name the folders with numbers, in the order you want them to be played.

2 Likes

Thanks for your time.

I have submitted this query https://www.qwant.com/?q=help+sort+mp3+files+for+car+usb-player and there are many people with the same problem.

The folder-names are actually sorted by the player (the folder list will show "Abbey Road" close to the top) , but the files aren't. So after copying the player starts in my case with "08 Because". If you plug the stick into a pc and open a dos-box in the correct folder and issue the "dir" command it will show the same natural order. A file-manager like total commander can show files in a panel sorted by name, date etc. but you can also select "unsorted" which will show the natural order the files are on disk.

Systems like fat do have an order in which they return filenames by default. It is the order in which they were put in. So if you want to control that order a copy or move command needs to execute in the processing order desired.

Oddly enough most file-managers process the copy or move commands in the correct order inside one folder.

As far as I know renaming does not change the natural order. So if I were to rename the files in the Abbey Road folder Because would still come up at the top.

I am therefore looking for a filemanager that can copy or move folders/subfolders/files according to the sort of the panel. Instead of just copying the files in their current order.

I appreciate your effort and time mbb but can you stop trying to change my question? Renaming will not change the order.

Not sure if this is something you might consider, but the find command in combination with the sort and copy command might do what you want.

Thanks. I am hoping it will be in one of the filemanagers, rather then having to resort to scripting.
One thing that does sort is packing. But packing 20gb of mp3s only to unpack them sorted seems a bit much. :frowning:

Ok, you can rename the files and then write a script to copy them one by one in the same order that is output by the ls command (equivalent to dir in dos).

For example:

[mbb@mbb-laptop ~]$ ls Music/PlayLists/
BassDrive.pls               SomaFM-BAGeLRadio.pls     SomaFM-Fluid.pls                 SomaFM-SevenInchSoul.pls  WeFunkRadio.pls
DiferentDrumz.pls           SomaFM-BlackRockFM.pls    SomaFM-GrooveSalad.pls           SomaFM-SonicUniverse.pls
Hot108Jamz.pls              SomaFM-BootLiquor.pls     SomaFM-IllinoisStreetLounge.pls  SomaFM-SuburbsOfGoa.pls
Jazz24.pls                  SomaFM-cliqhopidm.pls     SomaFM-LeftCoast70s.pls          SomaFM-ThistleRadio.pls
PsyStation-EthnicChill.pls  SomaFM-DubStepBeyond.pls  SomaFM-Lush.pls                  TSF.pls

As you can see, files are sorted by filename (let's assume these are the mp3s you renamed in the right order and want to copy - remember there are many tools for renaming).

Now, to echo files one by one in the same order, you can write the following command:

for i in $(ls); do echo $i; done

And the output is the following:

[mbb@mbb-laptop ~]$ cd Music/PlayLists/
[mbb@mbb-laptop PlayLists]$ for i in $(ls); do echo $i; done
BassDrive.pls
DiferentDrumz.pls
Hot108Jamz.pls
Jazz24.pls
PsyStation-EthnicChill.pls
SomaFM-BAGeLRadio.pls
SomaFM-BlackRockFM.pls
SomaFM-BootLiquor.pls
SomaFM-cliqhopidm.pls
SomaFM-DubStepBeyond.pls
SomaFM-Fluid.pls
SomaFM-GrooveSalad.pls
SomaFM-IllinoisStreetLounge.pls
SomaFM-LeftCoast70s.pls
SomaFM-Lush.pls
SomaFM-SevenInchSoul.pls
SomaFM-SonicUniverse.pls
SomaFM-SuburbsOfGoa.pls
SomaFM-ThistleRadio.pls
TSF.pls
WeFunkRadio.pls

To copy the files in that order, just substitute the command echo with the command cp:

[mbb@mbb-laptop PlayLists]$ mkdir targetfolder
[mbb@mbb-laptop PlayLists]$ for i in $(ls); do cp $i ./targetfolder/; done
cp: -r não especificado, a omitir a pasta 'targetfolder'
[mbb@mbb-laptop PlayLists]$ ls targetfolder/
BassDrive.pls               SomaFM-BAGeLRadio.pls     SomaFM-Fluid.pls                 SomaFM-SevenInchSoul.pls  WeFunkRadio.pls
DiferentDrumz.pls           SomaFM-BlackRockFM.pls    SomaFM-GrooveSalad.pls           SomaFM-SonicUniverse.pls
Hot108Jamz.pls              SomaFM-BootLiquor.pls     SomaFM-IllinoisStreetLounge.pls  SomaFM-SuburbsOfGoa.pls
Jazz24.pls                  SomaFM-cliqhopidm.pls     SomaFM-LeftCoast70s.pls          SomaFM-ThistleRadio.pls
PsyStation-EthnicChill.pls  SomaFM-DubStepBeyond.pls  SomaFM-Lush.pls                  TSF.pls

As you can see, all the files were copied to targetfolder. That little error just means I didn't specify the -r option and so the folder targetfolder, which was created in the same directory for demonstration, couldn't be copied (onto itself, go figure!).

Finally, to execute this repeatedly, you put the command in a script. So open a text file and copy the following over there:

#!/bin/bash

for i in $(ls); do
    cp $i $1
done

Where $1 is the target path. Remember to encapsulate $1 with "<path>" if the path has spaces (this is very important).

Save the file and then make it executable: chmod +x <saved-file>
Then execute it inside the folder where the files to be copied are:
<saved-file> "<target-path>"

I hope this solves your problem.

2 Likes

Thanks for the time and effort you must have put in. I appreciate it.

I have looked into the problem some more:

mc (midight commander) also has the ability to display files in their natural order (unsorted). So it is possible in Linux with a standard program to view that order too.

If one enters a folder in mc and sorts by name and then selects a couple of files they get processed in the order in the panel. So if one views them "unsorted" they are in the order of their names.
If you sort the panel by another column, that will be the order in which the files are copied. If the target is viewed "unsorted" you can see that they are physically ordered that way.

The ordering does not work for sub-directories however. If a directory is selected the "natural" order is maintained,

Simplest approach for dealing with sd/usb cards with mp3s:

  1. use fatsort after initial filling. That way the majority of files is sorted.
  2. If you add one or a couple of albums later: enter the folders using mc, select the name-sorts in the panel and move the files to a temp folder. Then move them back. Then they will be sorted.
  3. If you add large numbers: just run fatsort again.
    Best to use mc and view the target-folder sorted as "unsorted". That way you can immediately see if the tracks are in the correct order.

I'll keep looking for a way to sort folder-trees by name within a panelled file-manager.

I'd just get a different mp3 player...

Just dropping in to say thanks to @yotties for bringing my attention to fatsort.
One of my daughters has a radio with built in mp3 support which only plays the files in fat-table order so this will come in handy.

1 Like

It's built into the car. It plays cds with mp3s, bleutooth-sources etc all well. On the steering wheel I can switch tracks up/down and folders up/down. Most of it is great. In itself I do not mind dealing with it by manipulating its input, rather than performing all kinds of wizardry on the device.

But why doesn't the script work? If the problem lies in the order by which the files are copied, then it should work. If it doesn't, the problem lies somewhere else.

If the problem relates to subdirectories, it can also be solved by scripting. It's a matter of adaptation.

If you don't want to rename files, you can copy their names to a text file and then adapt the script to copy them by that order.

I have also found this site. May be useful.

Thanks for your time and effort. I really like the site you suggest. Useful.
Scripting, like most other programming, requires testing, versioning, backups etc.. So, even though I have created some scripts in dos, bash, rexx etc.. I prefer compiled parts of production ready programs like file-mangers. So I try to find solutions there first. I am unlikely to need it more than maybe 20 times, so programming/debugging etc. seems quite an investment to me.

I am a bit surprised that copying ordered, rather than in the natural/current order is not easily available. But that's the way it is.

Forum kindly sponsored by