2

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.

Documentation

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

...

0629e7bc-8110-4db9-aaa9-b67b0b73743d
06a409e1-98c6-4bf4-afa4-c814f7899d82
0a3a5c12-e459-4aa0-b9cb-30b544013215
0c14581f-31d8-4961-a14f-11afc40e47f9
0fe8970c-6338-46ca-bc16-f7867b271480
129855c4-7dbe-4a9f-a100-28b1d3d02340
1522e288-8a81-4298-aefc-f334cb088a53
180d430b-76f9-401f-845a-cb395bc1eba0
1a01a936-bedf-4758-971a-d4886ee8d281

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... – Steve Chambers Jun 26 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. – ankii Jun 26 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 Jun 27 at 5:27
  • 1
    Why do you have to go in a specific order. Why can't you use another? – user151019 Jun 27 at 13:56
2

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
        os.system(stri)
        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():
        f.write("%s,%s\n"%(key,thedict[key]))
  • 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 Jul 3 at 11:16

You must log in to answer this question.

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