You are not logged in.

#1 2007-10-08 18:02:49

firedance
Member
From: Stockholm, Sweden
Registered: 2005-04-18
Posts: 131

Files listed the wrong way (CD3,CD2,CD1 instead of CD1,CD2,CD3)

Ok, i have a server with samba where we put the familys music so we don't have to fight over the cdroms, this works fine but the problem is that when loading the music everything gets loaded the reverse order, instead of loading cd1 and its files and then cd2 and then cd3 it does cd3 first and cd2 then cd1. when doing ls on the folder the files appear the right order but if I do find they appear in the cd3,cd2,cd1 order.
What is the problem and is there a way to correct this? (file system is ext2 if that matters)

Offline

#2 2007-10-08 18:52:45

pooflinger
Member
From: Sweden
Registered: 2007-10-05
Posts: 53

Re: Files listed the wrong way (CD3,CD2,CD1 instead of CD1,CD2,CD3)

That's a feature, not a bug wink

Offline

#3 2007-10-08 19:14:58

robertp
Member
From: Warszawa, Poland
Registered: 2007-09-11
Posts: 123

Re: Files listed the wrong way (CD3,CD2,CD1 instead of CD1,CD2,CD3)

Force SMB client to sort list of files returned from server.

Offline

#4 2007-10-08 19:20:46

firedance
Member
From: Stockholm, Sweden
Registered: 2005-04-18
Posts: 131

Re: Files listed the wrong way (CD3,CD2,CD1 instead of CD1,CD2,CD3)

pooflinger wrote:

That's a feature, not a bug wink

How do I turn off this feature then? smile

robertp wrote:

Force SMB client to sort list of files returned from server.

I don't think this is a samba-only problem(feature) since it appears when I use find on the server.

Last edited by firedance (2007-10-08 19:21:14)

Offline

#5 2007-10-08 19:58:09

robertp
Member
From: Warszawa, Poland
Registered: 2007-09-11
Posts: 123

Re: Files listed the wrong way (CD3,CD2,CD1 instead of CD1,CD2,CD3)

I will explain it better.
ls program gets list of all files from directory, sorts the list and outputs it on the screen.
find doesn't do any sorting so filenames are returned in the order they are stored on disk which is usually different than alphabetical order.
If you want find to return them in alphabetical order try moving them back and forth (and maybe after some rounds you will succeed).

Your samba returns files just like find (without any sorting since it doesn't know client locale/language and thus sorting rules). But client does know your locale and is able to sort filenames correctly.

Offline

#6 2007-10-09 10:58:41

firedance
Member
From: Stockholm, Sweden
Registered: 2005-04-18
Posts: 131

Re: Files listed the wrong way (CD3,CD2,CD1 instead of CD1,CD2,CD3)

robertp wrote:

I will explain it better.
ls program gets list of all files from directory, sorts the list and outputs it on the screen.
find doesn't do any sorting so filenames are returned in the order they are stored on disk which is usually different than alphabetical order.
If you want find to return them in alphabetical order try moving them back and forth (and maybe after some rounds you will succeed).

Your samba returns files just like find (without any sorting since it doesn't know client locale/language and thus sorting rules). But client does know your locale and is able to sort filenames correctly.

Ok, I see.

So either I need a program that moves the files on ext2 (I remember seeing something like it for fat32 ment to be used on cheap mp3 players)
or then I need to patch samba to make it sort the files, I don't think i can change the client.

Offline

#7 2007-10-09 11:17:14

pooflinger
Member
From: Sweden
Registered: 2007-10-05
Posts: 53

Re: Files listed the wrong way (CD3,CD2,CD1 instead of CD1,CD2,CD3)

If all you need to do is to have find return a sorted list, and using a client like nautilus is not possible for your usage, then might I suggest piping the output of find to a sorter. To use this comfortably you can make it an alias.

find trackname | sort <parameters that you can specify according to manpages>

If you want more advanced functionality have a look at sed and/or awk. You might even find some good scripts for this by googling around.

Offline

#8 2007-10-09 12:01:24

firedance
Member
From: Stockholm, Sweden
Registered: 2005-04-18
Posts: 131

Re: Files listed the wrong way (CD3,CD2,CD1 instead of CD1,CD2,CD3)

No that is unfortunately not what I need.
-edit-
but i like your description of the arguments to sort smile

Last edited by firedance (2007-10-09 12:02:10)

Offline

Board footer

Powered by FluxBB