LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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



Reply
 
Search this Thread
Old 05-26-2008, 07:10 AM   #1
wizardhat
Member
 
Registered: Apr 2008
Location: Melbourne, Australia
Distribution: Slackware 12.2
Posts: 52
Blog Entries: 1

Rep: Reputation: 15
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:
$ 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?
 
Old 05-26-2008, 07:29 AM   #2
Takla
Member
 
Registered: Aug 2006
Distribution: Debian
Posts: 188

Rep: Reputation: 33
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.

Last edited by Takla; 05-26-2008 at 07:34 AM.
 
Old 05-26-2008, 07:33 AM   #3
Stéphane Ascoët
Member
 
Registered: Feb 2004
Location: Orleans, 120 km south of Paris
Distribution: Mandrake, Freeduc (the one I'm making), Slackware, MacOS X
Posts: 115

Rep: Reputation: 20
Thumbs down mp3 sucks

Just use a true hi-fi sound player... Or create a script that copies files in the numerical order.
 
0 members found this post helpful.
Old 05-26-2008, 07:52 AM   #4
Takla
Member
 
Registered: Aug 2006
Distribution: Debian
Posts: 188

Rep: Reputation: 33
Quote:
Originally Posted by Stéphane Ascoët View Post
Just use a true hi-fi sound player... Or create a script that copies files in the numerical order.
OP's question has nothing to do with the mp3 format sucking or not sucking.
 
Old 05-29-2008, 04:47 AM   #5
wizardhat
Member
 
Registered: Apr 2008
Location: Melbourne, Australia
Distribution: Slackware 12.2
Posts: 52
Blog Entries: 1

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Stéphane Ascoët View Post
Or create a script that copies files in the numerical order.
I'd do this, but I wouldn't know where to start. Hence the post in the newbie forum
 
Old 03-23-2010, 07:31 PM   #6
CQ1ST
Member
 
Registered: Oct 2005
Location: NewZealand
Distribution: Crunchbang, Slitaz, Puppy
Posts: 70

Rep: Reputation: 17
..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
 
1 members found this post helpful.
Old 11-24-2010, 09:10 AM   #7
crramirez
LQ Newbie
 
Registered: Nov 2010
Distribution: opensuse
Posts: 1

Rep: Reputation: 0
Thank you very much. I used it without the -r option. Works great!!
 
Old 05-10-2012, 02:03 AM   #8
mikeklimczak
LQ Newbie
 
Registered: May 2012
Posts: 2

Rep: Reputation: Disabled
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.
 
Old 05-10-2012, 06:48 PM   #9
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950
Another possible solution for people having this problem is fatsort.

http://fatsort.sourceforge.net/
 
1 members found this post helpful.
Old 05-23-2012, 01:38 AM   #10
CQ1ST
Member
 
Registered: Oct 2005
Location: NewZealand
Distribution: Crunchbang, Slitaz, Puppy
Posts: 70

Rep: Reputation: 17
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"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command to copy files/folders but skip bad/corrupt files?? leemoreau Linux - Newbie 2 04-02-2007 03:27 PM
Order files by last modifed Madone_SL_5.5 Linux - Newbie 1 12-13-2006 07:43 PM
Arranging Files In Alphabetical order swatward Linux - General 4 12-11-2006 09:14 PM
Order your copy now! ctt1wbw Ubuntu 2 01-10-2006 08:33 AM
what files must i edit in order to: fazaman Debian 1 02-23-2005 09:33 AM


All times are GMT -5. The time now is 12:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration