I couldn't figure it out how to sort folders by "name" in Finder. Now I know, that it's not possible. At least, according to what I think of, when I say sort by name. So I guess I need another tool.

Substrings of digits are sorted according to their numeric value, as opposed to sorting the actual characters in the number.


My task is, to go trough hundreds of folders alphabetically, and look at an image within each folder, and check for errors.

My workflow currently is:

  1. Copy the output of ls -la into excel
  2. get the folder names
  3. copy each row one by one into finder's search box
  4. check the contents of the folder
  5. I have a "notes" column in excel, where I can write my results

This is very tedious.

I would like to get the same sorting logic, as within in terminal.

Here are some sample folder names:

ls -la



folders in Finder

Could you recommend a tool, which can sort folders by name, alphabetically? I've tried Commander One, but sadly, it's using the same logic as Finder.

  • Have you tried using the "ls" terminal command? If it sorts as you like you can easily redirect the output to a file... Commented Jun 26, 2019 at 12:52
  • We could modify the workflow itself in a way to avoid sorting if you could tell how many images do you have in any folder? We can open/close them using some python script and you can write the errors in the respective rows since you have folder names from the terminal output.
    – anki
    Commented Jun 26, 2019 at 16:50
  • every folder has 1 image, in a series of sub folders. eg 0629e7bc-8110-4db9-aaa9-b67b0b73743d/v3/something/somethingElse/hereIsMyImage_with_a_random_filename.jpg
    – Tamás
    Commented Jun 27, 2019 at 5:27
  • 1
    Why do you have to go in a specific order. Why can't you use another?
    – mmmmmm
    Commented Jun 27, 2019 at 13:56

1 Answer 1


I hope running this python script works. TEST would have all the folders you mentioned. I have modified the workflow slightly to avoid messing with Finder and AppleScript. The final file can be opened in Excel.

import os
import fnmatch

import time
directory = "your/dirname/Desktop/TEST"
y = [x[0] for x in os.walk(directory)] 
y = y[1:]

thedict = {}
for one in y:
    thedict[one] = ""
#makes dictionary with all the folder names
for direc in thedict:
    matches = []
    for root, dirnames, filenames in os.walk(direc):
        for filename in fnmatch.filter(filenames, '*.jpg'):
            matches.append(os.path.join(root, filename)) 
    for photo in matches:
        stri = "open " + photo
        error = raw_input("error?")
        thedict[direc] = error
#Photo opens, you see it, close it, type the error in terminal and hit #enter.
#Then the next one comes up.
import csv
with open('outputf.csv', 'w') as f:
    for key in thedict.keys():
  • 1
    Awesome! Thanks! Small issues: I had python3 installed, and had to replace raw_input with input. When you are iterating over the folders, you are not filtering out folders which have no images in them. My images are in a series of sub folders, and only the deepest folders have images in them.
    – Tamás
    Commented Jul 3, 2019 at 11:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .