finder sort by extension? (.epub and .mobi are mixed)

OSX 10.9.4


How do I sort, or separate files in any way, distinguishing them by filetype?


I mean, separate them by using the last bit of the filename that begins with the dot?

This used to work.

MacBook Pro (17-inch Late 2011), OS X Mavericks (10.9.4)

Posted on Jul 31, 2014 1:14 PM

Reply
5 replies

Aug 1, 2014 4:28 AM in response to ankhank

The nearest way is to sort by kind. If you view the folder in list view which is available via the View menu, and then find the Kind column and click on it, it will sort by Kind.


This seems to work for me in Mavericks, I just did a quick test of a folder containing two .epub files, a folder, and two .mobi files the results were like this


file.epub

file2.epub

untitled folder

file.mobi

file2.mobi


When the same was sorted by filename it looks like


file.epub

file.mobi

file2.epub

file2.mobi

untitled folder

Aug 1, 2014 8:52 AM in response to John Lockwood

Odd, yourmethod doesn't work for me, with more than two of each type.


Try a few dozen files with various first letters in the filename and a mix of .mobi, .azw, .azw3, and .epub and see what you get, with a variety of filenames.


All of them have the "Kind" ebook, and clicking that colum just reverses the alpha sort order by first letter of the filename.


Has anyone familiar with UNIX got a suggestion of a way to do this?

-- sort by the file extension -- the dot and the characters after the dot

This ought to be doable at least from the Terminal?

Aug 1, 2014 9:42 AM in response to ankhank

I tested this in Mavericks 10.9.4 but I suspect the big difference is what applications you have installed that have registered themselves as capable of opening these files. I as an example have an applications that can open ePub files installed (Pages) but not Mobi files.


With regards to using Unix, the standard ls (list) command would list them in name order not kind order. The ls command does have support for listing in date (i.e. time) order, or size order, but not as far as I can see file extension or kind order.


ls = name order

ls -t = last modified order

ls -U = creation date order

ls -u = last accessed order

ls -S = size order


Ok, as ls by itself will not do the job on Mac (apparently the linux version has an extra option that would which is ls -X) we need to use multiple Unix commands added together to do this.


ls | rev | sort | rev


This 'lists' the file names, pipes it to rev which reverse the order of the characters which means the file extension is now at the beginning, sorts it, then reverse the order again. It may not be perfect as epub gets reversed to bupe and this may result in unexpected sorting, but at least each file extension is grouped together.


Here is my list result, first the default name order


file.epub

file.mobi

file2.epub

file2.mobi

untitled folder


now sorted by 'extension'


file2.epub

file.epub

file2.mobi

file3.mobi

file.mobi

untitled folder


Clearly this approach could be extended further to perhaps improve it more.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

finder sort by extension? (.epub and .mobi are mixed)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.