Sort Month and Year

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Turion
Posts: 30
Joined: 01 Jun 2012 20:46

Sort Month and Year

Post by Turion »

I have some folders named with the months of the year like

Code: Select all

April
August
December
February
January
July
June
March
May
November
October
September
What's the easiest way to sort these folders in the natural month order like this?

Code: Select all

January
February
March
April
May
June
July
August
September
October
November
December
Can the sort order be Windows Explorer friendly?

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Sort Month and Year

Post by highend »

You could use a custom column to get that kind of sorting

You have to use the custom column to sort the contents then...

The script:

Code: Select all

    $months = "January|February|March|April|May|June|July|August|September|October|November|December";
    $index = gettokenindex(<cc_base>, $months, , "i");
    return ($index) ? $index : 13;
How the setup of the cc looks like:
CC.png
And here is how it would look like:
CC in action.png
To see the attached files, you need to log into the forum.
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 66677
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Sort Month and Year

Post by admin »

Or you run this through the Address Bar:

Code: Select all

SortByList "January|February|March|April|May|June|July|August|September|October|November|December", "|";
(No, it's not Explorer friendly. Explorer cannot do this.)

RalphM
Posts: 2121
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Sort Month and Year

Post by RalphM »

Probably the easiest way that doesn't need any special handling afterwards would be to rename the folders to:
01_January
02_February
...
If you can live with the imperfection but simplicity of this approach.
Ralph :)
(OS: W11 25H2 Home x64 - XY: Current x64 beta - Office 2024 64-bit - Display: 1920x1080 @ 125%)

admin
Site Admin
Posts: 66677
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Sort Month and Year

Post by admin »

... using this Batch Rename pattern after the list is sorted as wished:

Code: Select all

<#01>_*

Turion
Posts: 30
Joined: 01 Jun 2012 20:46

Re: Sort Month and Year

Post by Turion »

@highend
Thanks for the illustrated solution! :tup:

@admin
Thanks! That's an awesome script! :appl:

@RalphM
Yeah, I was thinking the same thing. Thanks! :tup:

Post Reply