Sort by number at the end of the file name in Windows Explorer

2

1

I want to know how can I sort my files in Windows Explorer using the last two digits in the file name. I have the following files in my folder:

f00001.jpg
f00002.jpg
f00003.jpg
b00001.jpg
b00002.jpg
b00003.jpg

But I want to sort by the next way:

f00001.jpg
b00001.jpg
f00002.jpg
b00002.jpg
f00003.jpg
b00003.jpg

Is there a way to achieve this? I tried many "Group By" and "Sort By" options with no result. I'm using Windows 7 Professional SP1 32-bit.

user458186

Posted 2015-06-12T15:40:32.817

Reputation: 21

1No, this doesn't seem to be possible. – Karan – 2015-06-12T15:53:46.717

1Yes, there exists a way to achieve this; an uncomfortable way but exists via changing some Exif/TIFF metadata. The task is scriptable... – JosefZ – 2015-06-12T20:17:52.347

Adding numbers in EXIF tags for each image, displaying the appropriate column in Explorer and sorting by it is a cumbersome and impractical solution IMO. Far better to rename the files than to go to such ridiculous lengths. – Karan – 2015-06-14T16:55:30.087

why only the last 2 digits? So the digits before that will be sorted according to the normal lexicographical rules? – phuclv – 2019-03-17T09:12:45.730

Answers

1

I have a ruby command line script that does batch file renaming. It happened to handle your request nicely:

bren *.jpg -o "(\d+)/n"

You can find the script at: bren.rb

Note: I have setup my computer in such a way that I can invoke the script by it's name, which is most likely not the case on your computer. In that case, just invoke the script like this:

ruby <PATH TO SCRIPT>\bren.rb *.jpg -o "(\d+)/n"

Codism

Posted 2015-06-12T15:40:32.817

Reputation: 845

http://superuser.com/users/29956/codism Sorry for the silly question, but I need to have Ruby installed in my computer? And where I need to put the code to invoke? – user458186 – 2015-06-12T21:57:05.793

@user45816: Yes, you need ruby installed. I would suggest you to put the script in C:\rwin. However, you should be able to put the script anywhere you want. – Codism – 2015-06-13T02:06:57.490

@Codism: How will this possibly aid in sorting the files as required while retaining their existing names? If the files are going to be renamed anyway then the entire question is pointless. – Karan – 2015-06-14T16:58:52.990

@Karan: the command I gave does not perform renaming. What it does is to select all .jpg files in the current directory and order by the first number found in the file name. Without any "transformer", my program only lists the files are to be processed. You can find more information in the help message in the source code. – Codism – 2015-06-15T14:56:25.620

@Codism: So just to be clear, your program displays files ordered by the first number found in their names, and doesn't affect the sort order of Explorer itself, right? – Karan – 2015-06-19T07:47:53.220

@Karan: Yes. Files entries are usually ordered by their names when they are stored on disk. It's up to a particular tool to decide the order in which files are listed. – Codism – 2015-06-19T14:05:26.913

@Codism: TBH for someone who wants files to be displayed in a particular order in the OS' file manager itself, I don't see how using a separate program for ordering can be of any big help. I mean, the same can be done using Excel or similar too. (Just to be clear, this is not a comment on your program itself but its suitability in this situation to solve the OP's problem.) – Karan – 2015-06-19T15:03:08.093

@Karen: I am afraid the original request is too specific to be available in any general purpose file manager. – Codism – 2015-06-19T18:50:24.680

0

I can't comment yet but here is some information. You can have Windows 7 sort numerically.

I doubt there is a way to sort by the end of the filename though, that isn't standard anywhere and doesn't seem practical in most situations.

MC10

Posted 2015-06-12T15:40:32.817

Reputation: 7 590