Mailinglist Archive: opensuse (878 mails)

< Previous Next >
Re: [opensuse] copying files to USB flashdisk in alphabetical order
2013. szeptember 10. 3:23 napon Bernhard Voelker <mail@xxxxxxxxxxxxxxxxxxx>

On 09/07/2013 07:13 PM, Istvan Gabor wrote:

My old mp3 player plays the files in the order as they were copied
to the disk.

Until now I used to copy the files in the correct order by this command:

find . -print0 | sort -z | xargs -0 cp -a --parents

This used to copy directories and their files recursively in alphabetocal

But in openSUSE 12.2 it does not work. The files are copied to my sdcard
in random order.

Why is this and how could I fix it?

Unfortunately, you didn't write how the files are copied.
So my guesses out of the blue:

I don't understand what you mean "how files are copied".

I wrote I use cp -a --parents --target-directory=/media/disk

Did you verify that the output of sort(1) is what you expected?
Please try something like

Yes I tried. The command find . -print0 | sort -z | xargs -0

writes the names all the files and directories in alphabetical order
to the screen.

But as a general note: sort(1) is inherently dependent on the
current locale(1). Probably/maybe you want to set LC_ALL=C like

$ find . -print0 | LC_ALL=C sort -z | xargs -0 ...

I have en_US.UTF-8 locale and all the files and directory name in this folder
only iso latin1 characters. No accented characters.

The output is something like this:

. ./01 ./01/01.mp3 ./01/02.mp3 ./01/03.mp3 ./01/04.mp3 ./01/05.mp3 ./01/06.mp3
./01/08.mp3 ./01/09.mp3 ./01/10.mp3 ./01/11.mp3 ./01/12.mp3 ./02 ./02/01.mp3
./02/03.mp3 ./02/04.mp3 ./02/05.mp3 ./02/06.mp3 ./02/07.mp3 ./02/08.mp3
./02/09.mp3 ./02/10.mp3

Finally, find(1) will probably include and print the directories
first ... which will make the sorting order for cp(1) useless because
it will first copy the whole directory and then recognize that it has
to copy the files in it (which has already been done).
Did you mean this?

I think you are not right.

What is important, this command always worked in my
previous systems. In openSUSE 12.2 it does not work.
(I haven tested it in 12.1).

Since copying the files is pretty slow I can check
how the files are appearing on the sdcard.

They are appearing randomly, not in alphabetical
order. Directory 03 is created before 01, and
file 08 is created before 02, for example.

Might this be related to:

1) sync / async option of mounted media

2) temporary media filesystem

3) or something else?

Thank you for your answer.

To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups