Mailinglist Archive: opensuse (878 mails)

< Previous Next >
Re: [opensuse] copying files to USB flashdisk in alphabetical order
On 09/07/2013 07:13 PM, Istvan Gabor wrote:
Hello:

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
--target-directory=/media/disk

This used to copy directories and their files recursively in alphabetocal
order.

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:

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

$ find . -print0 | sort -z | xargs -0 printf "%s\n"

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
this:

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

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?

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

Have a nice day,
Berny
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups
References