Arranging Icons in Finder Icon View

That seems to be the fundamental drawback of Stickies and what limits it to being used when you only have a handful of Spaces/Desktops. That doesn't take away from your macros being a good starting point.

Just poking around inside the package of the installed DIM, in Contents/Resources, is the (not copy protected, thanks DIM author) AppleScript file, "DIM.scpt". In the "memorize()" function, it looks like it has commands to save positions of items in a Finder window - it also does this for the Desktop, which has a separate branch of commands. But it looks like it works for both. I've been following this thread with some interest - thought I'd just point this out, if you hadn't seen it yet. :slightly_smiling_face:

There's a chance I've forgotten a main requirement of all this, but... Could you name all the files with a prepended number and then use Finder's built-in Clean Up By Name function to set their position?

Thanks for pointer, Ed @edmechem, and the reminder. I've been meaning to look into that.

I have DIM installed and I've also downloaded the source from Github. I've been in contact with the developere, G.J. Parker, who gave me a detailed overview of how DIM works. If you are interested, I can pass that along.

He also kindly pointed out that Apple doesn't allow AppleScript-based apps into the App Store without very stringent guidelines. Fortunately for me, I have no intention of selling anything from this in the App Store.

Where I left it with him was that I'd look at his AppleScript functions in the DIM source and get back to him with questions. And instead I've been pursuing a different thread in this project.

Thanks, I had thought of that, but wasn't really enthusiastic. For my aesthetics, I would have to temporarily rename everything by adding the numbers, do the "Clean up", and then rename everything back. That requires messing with the filenames which seems risky to me. But maybe it wouldn't be so bad. I'll think about it. Maybe I can run a test. If I can rename 40 files, rearrange the icon order based on the new names, and rename them back again, and if it just happens pop, pop, pop, nearly transparentlfy, that would eliminate my having to write my own sorting and repositioning functions.

Back in Pos #9 in this thread, you suggested using the Comments field. I've been working on that concept as a way to have the "current" Desktop Number the file is open in attached to the file. That's the sort order that I'm trying to implement.

Also, not well explained as a requirement, is the task of actually getting the numbers in the first place and associating them with the files. Unlike DIM, which just "memorizes" the current positions in the current folder, I need to know which Desktop each file is open on. To collect that information all at once, in a single pass, requires stepping through all of the Desktops, one at a time. That's tedious. I've tried it for other things and I need to allow at least two seconds, if not more, for the Desktop to "settle" before I do things with it. To gather info from 40 Desktops means keeping my hands off the keyboard or mouse for nearly two minutes. That's not a productivity booster.

Using the files' Comments field means that I will not necessarily need to collect that information all at once, it can be updated as I go along, with each Desktop change, while I'm working. And it adds to a concept that I've had about this whole system, that I don't want some out-of-sight database to be in control, and which has to be tracked and updated Instead, the files themselves are the database.

That also, I think, solves one of the problems in the CurrentKey Stats app. Repeatedly, especially on reboot, CKS looses track of the correspondence between name and Desktop number/position which requires slowly stepping through all the desktops while it, one at a time, figures out if it knows the name of each Desktop. I don't know the details of his system or why that bug occurs, but I think it's because he's working from a central database of names and desktop numbers. I'm hopeful that having permanent files with the current Desktop number saved in the the Comments, updated when I make changes, will prevent anything like that particular problem/confusion.

BTW, I really appreciate all the suggestions and questions. It's encouraging to feel your interest and collaboration. And it helps me to sort out my thinking to explain it and to recall my decision making, especially since I may ultimately write it up as a tutorial.

1 Like

Hi @noisneil,

To get back to your previous question:

I gave you my prior rationalization without actually taking in the whole of your suggestion. Since this is actually a finite set of files, actually all collected in one folder, there is no real need for a separate file type. All I need to do is set the Open With property (System Events "default application" property) of each file so that it opens with DeskSpaceID (my TextEdit clone). Done. Opens in the desired app and keeps the RTF thumbnail.

I only have about 30 icon files so far, so the task of setting those Open With app names is a bit tedious, but totally doable by hand. In the long run, I'm looking at automating all the various settings (icon, comment, openwith, etc.) as well as the font changes in creating the display image that I like. For automating the Open With property, I now have help from @ccstone and @tiffle in the Set the “Open With” of a Finder selection? thread of @MitchellModel.

1 Like

Another of your suggestions that I initially shrugged off with my then current rationalization and which I am now implementing.

The RTF icon automatically gives a thumbnail of the file, and my 200pt initial letter is visible in the thumbnail. That's what I like and I like it a lot. And based on your suggestion I've come up with another way.

I take a screenshot of the Desktop with only the Desktop Workspace Identification Window (DTWSIW) visible. I can even use DIM to temporarily hide the desktop icons. I take a screenshot of that and paste it in on the Get Info dialog as the icon for the file. (It's saved in the file metadata at a relatively low resolution.)

The 200pt initial is still visible in the screenshot icon, it gets rid of the pesky turned down corner and "RTF" overlay on the icon and it carries through my use of the desktop wallpaper as an aid to identifying which Desktop is which. Here's what it looks like with four of them done (without the DIM enhancement yet).

So thanks again for the suggestions and my apologies for initially dismissing them.

1 Like

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.