Arranging Icons in Finder Icon View

I just replied to that thread. You can change the default app for all selected files at once by using ⌥⌘I.

I wish I'd seen this note a few hours ago. Instead I selected a bunch of files and pressed ⌘I, so I got an Info dialog for each file and had to change the default app for each one. About 30 drop-down menu selections went fairly quickly,

Your tip will come in handy shortly, however. I just modified that AppleScript script above in comment #28 to also display the default application property. Turns out that it's saved not by name, as in the dropdown menu, but rather by the full path to the application, which in my case is buried down in the Xcode Derived Data for my most recent build of the app:

Default Application: Macintosh HD 1T:Users:amohr:Library:Developer:Xcode:DerivedData:DeskSpaceID-busoliyvtbqvabdudgpcmlhzveju:Build:Products:Debug:DeskSpaceID.app:

So whenever I rebuild the app, I'll have to update the default application value for all these files, at least until I get the app to a state where I can install it in the Applications folder so the path is stable. Adding ⌥ to the ⌘I hotkey should make interim updates much less of a chore.

Thanks!

1 Like

This is...awe inspiring.

Truly a work of art.

1 Like

Thanks. I appreciate the comments. Along with collaborations like from @noisneil, it helps keep me thinking of how to share it, not just how to make it work for me, ideosyncratically.

I have this worked out. If Finder does not have the DeskSpaceIDs folder open in the current desktop, it closes it wherever it might be (using AppleScript) and opens it in the current desktop. It also highlights the current desktop using the KBM Reveal action.

Activate DeskSpaceIDs Window and Select Current Macro (v10.2)

Activate DeskSpaceIDs Window and Select Current .kmmacros (13 KB)

Keyboard Maestro Export

An intermediate task to the overall OP task of rearranging the icons is to determine the target positions and determine the order of the files. Major progress on both of those has been achieved in another thread.

This macro uses the KBM Get File Attribute action to get the comment property of each file, make a list entry with that number and the filename, sort the resulting list, and the extract just the filename from each line.

This list will be the list of files in Mission Control Desktop order.

This macro uses the AppleScript constructions above to create a list of positions and filenames, uses the UNIX sort command to do the two-level sort. It shows the resulting list of filenames sorted by icon position.

As I explained in the OP of that thread:

The update described is the ultimate goal of this thread's question.

BTW, I found another Forum thread from 2018 that contains the start of an answer to this question, dealing with moving one icon and finding the position coordinates of where you want to move it to.

It also uses AppleScript to both get and set the icon position.

Happy to find this thread. I have four, external drives connected to my Mac. So, there are five drives, arranged sequentially at the far right with Snap to Grid enabled: HD1 through HD5.

I have a brand-new Mac, running Ventura, and I've encountered a bug that moves HD3 and HD4 (just those two!) to a "random" spot, elsewhere on the screen, every time the display wakes. As a result, I'm moving those two icons back where they belong, several times a day.

I've seen the detailed suggestions above. But since my problem is slightly different from @August 's, I thought I'd ask, before digging in to the slightly intimidating solution, if the scripts above are likely to work for me, or if any modifications are recommended, based upon what I've described. I hope it's OK that I'm posting this here, rather than starting a new thread.

Thanks in advance.

Works for me.

As I understand it, the general rule on the forum is to keep topics "clean" to make it easier for people to find answers later. In one case, the topic wandered so far off yet had such useful info that I changed the title (it was my thread) to include the other topic. Recently (this week) another thread had a set of comments moved, split off, into their own thread. (I don't know how to do that and didn't even know it was possible until now, so in the future I might ask someone with those editorial powers to do that kind of thing.)

While this particular thread definitely has some digressions, I don't think they go that far. Since I started this thread, I'll unilaterally declare that your additional question seems very much on topic to me and definitely should help in providing more general solutions rather than being just about my specific case.

I don't think you'll be able to use the scripts verbatim, so you'll have to dig enough to be able to grasp what they are doing (not the same at all as being able to generate it). I hope the following is at the right level for you. I'm working off your phrase, "if any modifications are recommended" and I know that nothing above will work for you without modifications.

I would start by working on creating a script that will report to you what the position value is (combined x and y) for some specific icon on your desktop. In your case, it's the same situation all the time, so you could hard-code the name, rather than worrying about how to find or query for the name. At the very beginning of this thread, there is an example of AppleScript syntax for specifying desktop icons instead of Finder icons so that's part of your starting point.

When you are able get and display the position of the icon you want to move, make a note of the position value (x and y) for both of your target positions, where you want the icons placed. Then try modifying the AppleScript to set the value rather than geting it, to see if you can move it with your script. When you can do that, you're more than halfway home.

UPDATE: I was totally focussed on "the scripts above" and overlooked the reference to another thread:

That thread has two answers, one from @peternlewis about doing it entirely with KBM, in which he notes:

Then second answer from @ccstone uses AppleScript and does what I described above. It looks like it's exactly what you need.

2 Likes

Thank you. I understand, and I appreciate the comments. I'll investigate further.

@August I just wanted to thank you for referring me to @ccstone's solution in another thread. I've been really busy (and was frankly also dreading investigating this), but the AppleScript solution was straightforward, and it works!

I now have a KM macro that moves all icons to their correct place with a key command. (I'm also going to experiment with having it execute at log-in.)

Thanks again.

1 Like

I have been disappointed to discover that, while recent versions of TextEdit do maintain their Space across a restart, the versions of TE for which source is available, and which I used to create my DeskSpaceID.app dedicated clone, do not. So I've made a macro that assists in the restart-after-reboot process. Saving the Space Number in each DeskSpace Identifier File's comments field helps that process.