3

I have a folder of documents that I want to sort by the date they were created from oldest to newest. I know you can do this in list view, but I really want it to be in icon view.

I know that you can clean up by date created from the right-click menu, but that puts the newest files at the top, which is the opposite of what I want. Any help would be greatly appreciated.

3

You can do this using AppleScript:

tell application "Finder"
    activate
    set theFolder to insertion location
    set theWindow to container window of theFolder
    if the current view of theWindow is not icon view then error "This script is for folders in icon view"

    set iconSpacing to 0.85 * (icon size of icon view options of theWindow)
    get theWindow's bounds
    set windowWidth to ((item 3 of the result) - (item 1 of the result))

    set itemList to (sort (every item in theFolder) by creation date)

    set nextPoint to {iconSpacing, iconSpacing}
    repeat with thisItem in itemList
        set position of thisItem to nextPoint

        -- Move nextPoint on.
        set item 1 of nextPoint to (item 1 of nextPoint) + iconSpacing * 2
        if (item 1 of nextPoint) + iconSpacing is greater than the windowWidth then
            set item 1 of nextPoint to iconSpacing
            set item 2 of nextPoint to (item 2 of nextPoint) + iconSpacing * 2.2
        end if

    end repeat
end tell

Copy the above script into Script Editor, which is found in the Utilities folder inside Applications.

To make it more convenient to run the script, you can enable the macOS Script menu or use a third-party program like FastScripts.

  • I'm not providing an answer. This is a comment. Having this script is great, @RyanCu. Using Mac OS X 10.14.6, though, it has the icons seriously overlapping each other. I'll be messing around now with AppleScript and the dictionary for Finder, but it would be great to have some clues on how to change that. Thanks for the post, regardless, RyanCu! – Chris Oct 26 at 1:57

You must log in to answer this question.

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