You are not logged in.

#1 2009-08-05 14:39:39

Nazgulled
Member
Registered: 2009-03-08
Posts: 102

How to sort files and folders like Windows

I don't know if this is specific to Arch or every other Linux distro but one thing that really bugs me in Arch is how files and folders are sorted. I use Windows as my main OS (don't start on that please) and I have one folder properly organized exactly as I want it and I like it how Windows sorts this. I access that same folder from my Arch installation, the problem is that the sorting is different and it gets on my nerves lol...

This is how Windows sorts that specific folder:

C:\Users\Nazgulled\Documents\University>dir /O
 Volume in drive C is Vista
 Volume Serial Number is F84E-02BE

 Directory of C:\Users\Nazgulled\Documents\University

05-08-2009  15:34    <DIR>          .
05-08-2009  15:34    <DIR>          ..
05-08-2009  11:10    <DIR>          [Archives]
05-08-2009  14:38    <DIR>          [Developers]
05-08-2009  11:17    <DIR>          [X] 1) Cálculo II
05-08-2009  11:18    <DIR>          [X] 2) Análise de Custos
05-08-2009  11:18    <DIR>          [X] 2) Cálculo de Programas
05-08-2009  11:18    <DIR>          [X] 2) Laboratórios de Informática III
05-08-2009  11:18    <DIR>          2) Algoritmos e Complexidade
05-08-2009  11:18    <DIR>          2) Arquitectura de Computadores
05-08-2009  11:18    <DIR>          2) Comunicaçao de Dados
05-08-2009  11:18    <DIR>          2) Engenharia Económica
05-08-2009  11:18    <DIR>          2) Estatística Aplicada
               0 File(s)              0 bytes
              13 Dir(s)  24.700.485.632 bytes free

And this is how Arch does it:

nazgulled ~/University $ ls -l
total 7
drwxr-xr-x 1 nazgulled nazgulled  4096 2009-08-05 11:18 2) Algoritmos e Complexidade
drwxr-xr-x 1 nazgulled nazgulled  4096 2009-08-05 11:18 2) Arquitectura de Computadores
drwxr-xr-x 1 nazgulled nazgulled  4096 2009-08-05 11:18 2) Comunicação de Dados
drwxr-xr-x 1 nazgulled nazgulled  4096 2009-08-05 11:18 2) Engenharia Económica
drwxr-xr-x 1 nazgulled nazgulled  8192 2009-08-05 11:18 2) Estatística Aplicada
drwxr-xr-x 1 nazgulled nazgulled  4096 2009-08-05 11:10 [Archives]
drwxr-xr-x 1 nazgulled nazgulled  4096 2009-08-05 14:38 [Developers]
drwxr-xr-x 1 nazgulled nazgulled  4096 2009-08-05 11:17 [X] 1) Cálculo II
drwxr-xr-x 1 nazgulled nazgulled 12288 2009-08-05 11:18 [X] 2) Análise de Custos
drwxr-xr-x 1 nazgulled nazgulled  4096 2009-08-05 11:18 [X] 2) Cálculo de Programas
drwxr-xr-x 1 nazgulled nazgulled  4096 2009-08-05 11:18 [X] 2) Laboratórios de Informática III

How can I get Arch/Linux to sort exactly the same as Windows?

Last edited by Nazgulled (2009-08-05 14:41:47)

Offline

#2 2009-08-05 14:52:49

Lexion
Member
Registered: 2008-03-23
Posts: 510

Re: How to sort files and folders like Windows

ls -l | sort

or maybe

ls -fl --color=yes | sort

The second may be more minimal.  Sort has some other options that you can try, too.

Last edited by Lexion (2009-08-05 14:53:32)


urxvtc / wmii / zsh / configs / onebluecat.net
Arch will not hold your hand

Offline

#3 2009-08-05 15:14:58

majiq
Member
Registered: 2009-03-06
Posts: 259

Re: How to sort files and folders like Windows

I guess the best would be

 ls -l | sed '/^total/d' | sort -k 9

That gets rid of the total line, because otherwise it ends up squished somewhere in between. The above got me to

-rw-r--r-- 1 majiq majiq 0 2009-08-05 11:08 [Archives]
-rw-r--r-- 1 majiq majiq 0 2009-08-05 11:08 [Developers]
-rw-r--r-- 1 majiq majiq 0 2009-08-05 11:08 [X] 1) Cálculo II
-rw-r--r-- 1 majiq majiq 0 2009-08-05 11:09 [X] 2) Análise de Custos
-rw-r--r-- 1 majiq majiq 0 2009-08-05 11:09 [X] 2) Cálculo de Programas
-rw-r--r-- 1 majiq majiq 0 2009-08-05 11:09 [X] 2) Laboratórios de Informática III
-rw-r--r-- 1 majiq majiq 0 2009-08-05 11:07 2) Algoritmos e Complexidade
-rw-r--r-- 1 majiq majiq 0 2009-08-05 11:08 2) Arquitectura de Computadores
-rw-r--r-- 1 majiq majiq 0 2009-08-05 11:08 2) Comunicação de Dados
-rw-r--r-- 1 majiq majiq 0 2009-08-05 11:08 2) Engenharia Económica
-rw-r--r-- 1 majiq majiq 0 2009-08-05 11:08 2) Estatística Aplicada

Offline

#4 2009-08-05 18:07:27

Nazgulled
Member
Registered: 2009-03-08
Posts: 102

Re: How to sort files and folders like Windows

I'm sorry, I should have specified... I just showed command line examples cause it would be easier to list, copy and paste into the forums...

I don't use the command lines that much, was really just to use as an example.

What I really care about is to sort all folders (not just this folder specifically) like Windows does it, in Nautilus, cause that's what I use on my Arch box.

Of course, I also like to see things sorted properly when I use bash, but I dislike your solutions because what I'm looking for is to change the default sort order used by the system and not require me to type a big command just to sort the way I want it (I know I could create an alias, but that's beside the point).

Is it possible then?

Offline

#5 2009-08-05 20:55:15

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: How to sort files and folders like Windows

> the problem is that the sorting is different and it gets on my nerves

Yeah, I know what you mean.
The sorting order is called collation. You can try various locales here:
http://demo.icu-project.org/icu-bin/loc … col&_=root

I have no idea about Nautilus as I use the command line, but setting your locale may be the only thing you need to do. You can check your current settings just by typing "locale" at the prompt.

Offline

#6 2009-08-05 21:06:12

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

Re: How to sort files and folders like Windows

Nautilus should sort dirs, then files automatically. Just make sure you are sorting by name in the Nautilus prefs.  As for sorting case-insensitive, as someone mentioned already it has do to with your LC_COLLATE environment variable.  I think mine is set as LC_COLLATE=en_CA.utf8 (I'm at work so can't check).

Here's a related bug ticket which sheds some light on the subject:

http://bugs.archlinux.org/task/10435

Last edited by thayer (2009-08-05 21:09:04)


thayer williams ~ cinderwick.ca

Offline

#7 2009-08-05 21:27:02

Nazgulled
Member
Registered: 2009-03-08
Posts: 102

Re: How to sort files and folders like Windows

@karol
I can't see how that site helps me, what do I have to do? Even if it's just a fix for the command line, how can I fix it?

My current locale settings are:

nazgulled ~ $ locale
LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE=en_US.utf8
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=

@thayer
I know there are some issues with sorting case-insensitive stuff but the problem here, as I can understand it, is the folders name with brackets, which in Windows are sorted first and the comes the numbers, while on Linux, numbers come first.

Also, as you can see, I've already changed the LC_COLLATE from 'C' to from 'en_US.utf8' in /etc/profile and the problem remains...

Offline

#8 2009-08-05 21:57:06

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: How to sort files and folders like Windows

> Also, as you can see, I've already changed the LC_COLLATE from 'C' to from 'en_US.utf8' in /etc/profile
> and the problem remains...

Do you use that collation on Windows? CP1250 or sth similar seems more likely. I don't know whether it is possible to use the exact locales you have on Vista but first you should check what is what you want to copy to Arch.
http://www.collation-charts.org/vista/

Offline

#9 2009-08-05 22:11:34

quarkup
Member
From: Portugal
Registered: 2008-09-07
Posts: 497
Website

Re: How to sort files and folders like Windows

Nazgulled, you can change the locale settings to portuguese by changing the /etc/locale.gen file

uncommenting the lines you want

and then run the command
locale-gen (as root)


If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is.
Simplicity is the ultimate sophistication.

Offline

#10 2009-08-05 23:40:38

Nazgulled
Member
Registered: 2009-03-08
Posts: 102

Re: How to sort files and folders like Windows

quarkup wrote:

Nazgulled, you can change the locale settings to portuguese by changing the /etc/locale.gen file

uncommenting the lines you want

and then run the command
locale-gen (as root)

I know, I've done that in the past. But that doesn't solve the problem described in this topic.

And besides money currencies, time, dates, numbers decimal format and sorting order apparently, I like to keep everything (the OS and all applications) with English interface, that's why I have the locales set to en_US.

But like I said, changing it to Portuguese didn't help the sorting problem the last time I tried...

Offline

#11 2009-08-06 00:09:10

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: How to sort files and folders like Windows

> But like I said, changing it to Portuguese didn't help the sorting problem the last time I tried...

http://www.collation-charts.org/vista/v … razil.html
and
http://www.collation-charts.org/fbsd54/ … 859-1.html
represent different sorting orders.
ISO and UTF8 probably won't work for you, CP1252 might do the trick.

Offline

#12 2009-08-06 11:28:26

Nazgulled
Member
Registered: 2009-03-08
Posts: 102

Re: How to sort files and folders like Windows

Actually it's this one: http://www.collation-charts.org/vista/v … tugal.html

But there's a problem, there's no such collate option in /etc/locale.gen

How do I do it then?

Offline

#13 2009-08-06 12:23:54

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: How to sort files and folders like Windows

> But there's a problem, there's no such collate option in /etc/locale.gen

As I've already written, I don't know whether it is possible to use on Arch the locales you have on Vista.


> I have one folder properly organized exactly as I want it and I like it how Windows sorts this.

Sorry, I don't know how to help you. I sympathise w/ you, because it seems it's so simple yet so hard to achieve.
As an aside, you've probably heard you shouldn't use spaces in file names (and folders names) but you do it anyway, so it's really up to you to figure it out.

Maybe you can change "[ ]" to "( )":
[Archives]            -> (Archives)
[X] 1) Cálculo II   -> (X) 1) Cálculo II

Offline

#14 2009-08-06 12:42:38

Nazgulled
Member
Registered: 2009-03-08
Posts: 102

Re: How to sort files and folders like Windows

I don't know where that comes from, but I've always used spaces in file names and will always continue to do so, I'm not using MS-DOS anymore... And that has nothing to do with my sorting problems.

Nope, I don't like the ( ) instead of [ ], it looks ugly.

Thanks for trying to help smile

Last edited by Nazgulled (2009-08-06 12:43:06)

Offline

#15 2009-08-06 14:40:01

Trent
Member
From: Baltimore, MD (US)
Registered: 2009-04-16
Posts: 990

Re: How to sort files and folders like Windows

Personally, I don't like using spaces in file names because (1) they cause ambiguities when ls'ing directories, (2) it makes them ugly when putting things on the Web, and (3) I just like to keep my filenames short and let the directory structure describe their purpose (I don't understand how some people can seemingly keep all their documents on the desktop).

I'm really kind of confused by the brackets though.  Just... why?  Not to be critical.

Offline

#16 2009-08-06 14:57:12

Nazgulled
Member
Registered: 2009-03-08
Posts: 102

Re: How to sort files and folders like Windows

Well, all that is irrelevant really and a matter of personal taste. I have no interest in discussing it, sorry.

Anyone else has any suggestions on how this might be "fixed"?

Offline

#17 2009-08-06 15:08:33

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: How to sort files and folders like Windows

Trent wrote:

I don't understand how some people can seemingly keep all their documents on the desktop.

That's what the desktop metaphor leads to ;-)

It's easy to overlook all the under-the-hood machinery needed to perform even simple tasks. A lesson in humility maybe?

Nazgulled wrote:

Anyone else has any suggestions on how this might be "fixed"?

You have to precede "[" w/ sth the sorting order will put before numbers:
([Abracadabra]
"[Abracadabra]
'[Abracadabra]

I think it still looks ugly.

Last edited by karol (2009-08-06 15:15:08)

Offline

#18 2009-08-06 19:27:37

Trent
Member
From: Baltimore, MD (US)
Registered: 2009-04-16
Posts: 990

Re: How to sort files and folders like Windows

Nazgulled wrote:

Well, all that is irrelevant really and a matter of personal taste. I have no interest in discussing it, sorry.

Anyone else has any suggestions on how this might be "fixed"?

Didn't mean to cause offense; I was just curious.

Offline

#19 2009-08-06 20:01:15

Nazgulled
Member
Registered: 2009-03-08
Posts: 102

Re: How to sort files and folders like Windows

@Trent
I wasn't offended, it's just something I don't care to discuss.

@Karol
Thanks but I don't want to precede or rename the folders at all, that's unacceptable for me. Surely there must be a way to have the same sorting collation in Linux like in Windows hmm

Offline

#20 2009-08-06 22:23:43

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: How to sort files and folders like Windows

I "fixed" a locale definition file for you - it works in command line "ls -l" but may not work in Nautilus - does it suit you?

Offline

#21 2009-08-07 01:59:15

Nazgulled
Member
Registered: 2009-03-08
Posts: 102

Re: How to sort files and folders like Windows

What do you mean by that? I don't get what you are talking about... hmm

Offline

#22 2009-08-07 02:12:06

toad
Member
From: if only I knew
Registered: 2008-12-22
Posts: 1,775
Website

Re: How to sort files and folders like Windows

Nazgulled wrote:

Surely there must be a way to have the same sorting collation in Linux like in Windows hmm

Ah, no. The way they are doing it is nonsensical and not good practice for a unix style system. Having said that, some solutions have already been offered in this thread.

While you are free to continue to ask others to help you achieve your aims, it may be more convenient for you to adapt to a structure that is displayed the same way under all systems (just to avoid frustration - not saying you _should_ do it wink ).

Just my 2 cents' worth


never trust a toad...
::Grateful ArchDonor::
::Grateful Wikipedia Donor::

Offline

#23 2009-08-07 02:49:27

Nazgulled
Member
Registered: 2009-03-08
Posts: 102

Re: How to sort files and folders like Windows

toad wrote:
Nazgulled wrote:

Surely there must be a way to have the same sorting collation in Linux like in Windows hmm

Ah, no. The way they are doing it is nonsensical and not good practice for a unix style system. Having said that, some solutions have already been offered in this thread.

While you are free to continue to ask others to help you achieve your aims, it may be more convenient for you to adapt to a structure that is displayed the same way under all systems (just to avoid frustration - not saying you _should_ do it wink ).

I really don't care if it's nonsensical, I use Windows 95% of the time or more, it's my main OS, I'm used to it and I like it. Why should I care if it's not a good practice for a unix style system? I just want things to behave the way I like and for a free system like Linux where it doesn't even compare to Windows in terms of freedom in what I can do with it and configure the way I like, it sure is hard to change the way folders/files are sorted...

It sucks that there isn't a proper solution but I'm not going to adapt anything, that would be nonsensical... But if I have to, I can live with the fact that there isn't a good solution and leave it as it is smile

Thanks everyone for their input, "topic closed".

Offline

#24 2009-08-07 03:28:43

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: How to sort files and folders like Windows

Nazgulled wrote:

Why should I care if it's not a good practice for a unix style system?

Because you're trying to use a unix-style system, and it's not working how you're used to in a Windows-style system? wink

I think at the end of the day, this may just be one of those differences between Windows and *nix that is part of what makes them different.

Last edited by fukawi2 (2009-08-07 03:29:07)

Offline

#25 2009-08-07 03:39:51

Nazgulled
Member
Registered: 2009-03-08
Posts: 102

Re: How to sort files and folders like Windows

fukawi2 wrote:
Nazgulled wrote:

Why should I care if it's not a good practice for a unix style system?

Because you're trying to use a unix-style system, and it's not working how you're used to in a Windows-style system? wink

Let me rephrase than... Why should I care if something it's not a good practice for a unix style system, something I barely use and use because and when I have to? I can answer that, I shouldn't... And I don't, my main system is Windows, I couldn't care less about good unix practices, I just want things to behave the way I like it. That simple smile

This may be a difference between them, but there's no reason not to be able to configure the system to our liking, to mine in this case. Well, I know there must be way, it's just probably too much work...

Offline

Board footer

Powered by FluxBB