Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've got an mp3 player that stores files in the order that they are written. Unfortunately, when I copy a directory to my mp3 player, it copies the files in a seemingly random order (I say "seemingly" because running the same cp command again copies them in the same strange order). My problem is that, you guessed it, this screws up the play order.
Is there any way around this, barring copying everything one by one (by hand, which gets tedious)?
Here's an example of what I'm talking about:
Quote:
$ cp -rv /mnt/hd/mp3/Warren\ Zevon/Learning\ To\ Flinch/ .
`/mnt/hd/mp3/Warren Zevon/Learning To Flinch/' -> `./Learning To Flinch'
`/mnt/hd/mp3/Warren Zevon/Learning To Flinch/06-The French Inhaler.mp3' -> `./Learning To Flinch/06-The French Inhaler.mp3'
`/mnt/hd/mp3/Warren Zevon/Learning To Flinch/02-Lawyers, Guns & Money.mp3' -> `./Learning To Flinch/02-Lawyers, Guns & Money.mp3'
`/mnt/hd/mp3/Warren Zevon/Learning To Flinch/12-Jungle Work.mp3' -> `./Learning To Flinch/12-Jungle Work.mp3'
`/mnt/hd/mp3/Warren Zevon/Learning To Flinch/01-Splendid Isolation.mp3' -> `./Learning To Flinch/01-Splendid Isolation.mp3'
`/mnt/hd/mp3/Warren Zevon/Learning To Flinch/03-Mr. Bad Example.mp3' -> `./Learning To Flinch/03-Mr. Bad Example.mp3'
`/mnt/hd/mp3/Warren Zevon/Learning To Flinch/13-Piano Fighter.mp3' -> `./Learning To Flinch/13-Piano Fighter.mp3'
etc etc etc
This was just ripped from a cd in sequential order, so I'm not sure why it's coming out like that. Can anyone help me out here?
The problem isn't the cp command, it's the firmware and FAT filesystem on your mp3 player. It can only display the files in the order written to disk (you can see the same behaviour on older flash drives). If you transcode a folder of music on your PC and look at your encoder's output in the terminal you'll see that the files are not in alphanumeric order and are dealt with one by one in the order that they physically lie on the disk. Fortunately the OS filemanager and command line utilities by default display everything ordered nicely in the way we like.
An easy workaround is to first create a folder on the mp3player like "Warren Zevon - Learning to Flinch" and then copy the music files from the PC into that folder using your file manager. They should now appear on your mp3 player sorted alphanumericaly. This works for me on my cheap cheap chinese mp3 player using emelfm2 file manager.
..the answer is:
ls -t
(shows the problem)
cd MusicToMove/
find . -print0 | sort -zr | xargs -0 cp --parents
--target-directory=/media/disk/MUSIC/FoldersMoved
(fixes the problem)
..in sort -zr ,the r may be optional ,I've tested this on computer ,not an mp3player
I know this thread is bit old now, but we had a similar frustration. We copy large amounts of data using the "cp -Rv" command and it's annoying that the copy is not completed alphabetically because if it was we could tell at a glance how far through the copy the job was. We instead use "rsync -av" now and the copy is much easier to monitor.
I'd love to see the gui use this rsync -avP by default [someday] as it's infuriating to find this flaw (in both windows and linux) is the standard behaviour when solutions are (and have been for some time) available.
I saw later that month, that the windows xp computers at (one of) my local library copied all files alphabetically, and remember thinking "what a clever techie, sorting this .. as [any] tech 'would' when copying albums/songs was a feature used often by his/her patrons"
..the answer is:
ls -t
(shows the problem)
cd MusicToMove/
find . -print0 | sort -zr | xargs -0 cp --parents
--target-directory=/media/disk/MUSIC/FoldersMoved
(fixes the problem)
..in sort -zr ,the r may be optional ,I've tested this on computer ,not an mp3player
This was great help to me! My mp3s are sorted alphabetically rather than by date of simultaneous copy. Is there anyway to reverse the descending order to ascending?
This was great help to me! My mp3s are sorted alphabetically rather than by date of simultaneous copy. Is there anyway to reverse the descending order to ascending?
Take a look at the sort utility and whether or not you want the -r option. If you have questions about that please do ask as many as you have, but in a new thread. It is best to start a new thread insted of continuing one so old like this one.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.