Arranging Icons in Finder Icon View

I have not heard back from the DIM author yet, but it's not necessary.

You and I both bought into the idea that somehow this was a desktop-only thing and that was reinforced when ...

RUBBISH

I found a reference in Ask Different that used position and bounds of files in a folder (https://apple.stackexchange.com/questions/314456/mac-os-finder-read-file-folder-order-positions-arrange-by-thru-command-line) so I hacked together a script using them that was more like psuedo-code:

-- THIS IS BAD CODE
tell application "Finder"
	set fileList to every file in folder POSIX file "/Users/amohr/Documents/Personal/DeskSpaceIDs/"
	for every thisFile in fileList
		set thisName to get the name of thisFile
		set thisPosition to get position of thisFile
		set thisBounds to get bounds of thisFile
		set thisComment to get comment of (thisFile as alias)
	end
end tell

Of course it didn't run. But I gave it to ChatGPT as a starting point and ChatGPT helped me create this script:

tell application "Finder"
	set folderPath to POSIX file "/Users/amohr/Documents/Personal/DeskSpaceIDs/"
	set fileList to every file in folder folderPath
	set resultText to ""
	repeat with thisFile in fileList
		set thisName to name of thisFile
		set thisPosition to position of thisFile
		set thisBounds to bounds of thisFile
		set thisComment to comment of thisFile
		
		-- Format the position property
		set formattedPosition to item 1 of thisPosition & ¬
						", " & item 2 of thisPosition
		
		-- Format the bounds property
		set formattedBounds to item 1 of thisBounds & ¬
						", " & item 2 of thisBounds & ¬
						", " & item 3 of thisBounds & ¬
						", " & item 4 of thisBounds
		
		set resultText to resultText & "Name: " & thisName & linefeed
		set resultText to resultText & "Position: " & formattedPosition & linefeed
		set resultText to resultText & "Bounds: " & formattedBounds & linefeed
		set resultText to resultText & "Comment: " & thisComment & linefeed & linefeed
	end repeat
end tell

-- Display the result in a dialog
display dialog resultText with title "File Info" buttons {"OK"} default button "OK" giving up after 30

Try it on a folder of your own. Add some comments to files using File > Get Info.

Formatting the position and bounds values that way was something I suggested to ChatGPT because it had never gotten the concept that those values were lists. It was writing a "format handler" that reset the list delimiter before assigning the list to a variable and that was just not working. Again I suggested a method using psuedo-code ("position[1] & ", " & position[2]") and it gave me the proper AppleScript syntax.

So, OK, I'm getting to like coding with ChatGPT's help. It does require that I know what it is that I want to do because it cannot figure that out for me. And it will cheerfully go down rabbit holes of stuff that doesn't work and then authoritatively declare that there is no way, and be dead wrong. But as a robot, it's useful.

1 Like