How do I get cp to copy files in the right order?
Hey all,
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:
|
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. |
mp3 sucks
Just use a true hi-fi sound player... Or create a script that copies files in the numerical order.
|
Quote:
|
Quote:
|
..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 |
Thank you very much. I used it without the -r option. Works great!!
|
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.
We have a full description of the solution on our offsite backup website here. |
Another possible solution for people having this problem is fatsort.
http://fatsort.sourceforge.net/ |
Thank you Mike for your post/answer.
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" |
Quote:
|
Quote:
|
All times are GMT -5. The time now is 11:50 PM. |