[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sort files by name and maintain sort order when copying to mp3 player

On Mon, Mar 24, 2008 at 09:09:22 -0200, Eduardo M KALINOWSKI wrote:
> On Mon, Mar 24, 2008 at 7:06 AM, Russell L. Harris wrote:
> > After two hours of searching with Google and Yahoo, I have not found a
> >  good approach to the problem of maintaining proper file order when
> >  copying mp3 files from an ext3 directory to a flash-based mp3 player.
> >
> >  Contrary to the instruction manual, the player (a Creative MUVO) plays
> >  files in the order in which they are written to flash memory, so if I
> >  have an audio book with a hundred chapters on an ext3 drive and then
> >  copy the book to the mp3 player, the chapters do not necessarily play
> >  in proper sequence.
> I had a similar problem with a lousy mp3 player. What I did was copy
> the files directory by directory.
> This does not work:
> cp -r ~/mp3/a_directory /mnt/usb
> This works and mantains the order:
> mkdir /mnt/usb/a_directory
> cp ~/mp3/a_directory/* /mnt/usb/a_directory
> It is certainly a pain in the ass if there are several directories,
> but at least it works. The * gets expanded to a file list in
> alphabetical order.

What about this:

find /your/source/ | sort | while read FILE; do cp "$FILE" /your/destination/; done

Maybe you want to check the sort order before you do the actual copying:

find /your/source/ | sort | while read FILE; do echo "$FILE"; done

The sort command has various options to influence the sorting order; it
might also depend on your LC_COLLATE setting (I am not sure about this).

You can also use the find + sort combination to compile a rough

find /your/source/ | sort > playlist.txt

Then you can edit this playlist and afterwards copy the files in the
same order as they appear in the modified playlist:

while read FILE; do cp "$FILE" /your/destination/; done < playlist.txt

Regards,            | http://users.icfo.es/Florian.Kulzer
          Florian   |

Reply to: