Clean up by date created in reverse order

findersort

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.

Best Answer

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.