Dynamically-Updating Palette Based on Folder Structure

Hi everyone.

I have a terabyte of music samples of different types (kicks, snares, vocal samples, etc) that I go through regularly in Finder. Often I want to "favorite" one by copying it into a designated folder for its type.

The designated folders are all in a master "Favorite Samples" folder, containing sub-folders for each type, sometimes several levels deep for sub-types.

The hierarchy you see in the screencap below just matches the folder hierarchy in Favorite Samples, pretty simple.
ex1v2
I'm using sub-palettes, which is static and very manual. The Favorite Samples folder structure is constantly iterating and I have to create & maintain a macro for each folder, which is ineffective for something I will be changing for the rest of my life. (This is already taking 40 macros, and I just started.)

So I'd really like a solution where the list dynamically-updates based on the folder structure of "Favorite Samples".

(The 'Ω Drop Here' option puts the sample in the current hierarchy. An OK button would be a good substitute, if we needed to do a custom HTML prompt.)

:pray:t3: in advance.

Hey @nrightnour

I definitely do not know how to do this and I’m engaged is a related conversation over here looking to simplify filing and the ongoing updating of structures to do that. Stop over and see if it inspires anything for you.

Thanks @BernSh, I'll check that out.

I am willing to use Applescript, but I have little experience with it.

Here is someone else's attempt at something similar using AS:

Another way of going about this... similar to what I'm doing now, but using a plist/text file instead of "listing contents of folder x" to generate palette entries.

Have a text/plist file with one line for each user-desired destination (e.g. Drums > Kicks), which automatically creates palette entries for each line (and sub-palettes for each >, for easier navigating). Each palette entry does this: enter %favorite samples folder%, checks if folder "Drums/Kicks" exists (if not, create it), then copy file to it.

Definitely not as graceful, but way better than what I'm doing in KM now, with a macro for each entry.

Following up on this months later.. it's still something I deal with all the time.

Any proposed solutions welcome.

I'm in the same boat. I have hundreds of Logic sessions all over my various drives and I'm trying to categorise them by project, level of completion, genre etc. Did you ever figure this out?

I think perhaps AppleScript might be a good route, as it would mean undo steps would be available, in case, like me, you're occasionally clumsy and then have no idea where you just sent a file whose name you didn't even make a mental note of.

@nrightnour Would you be willing to share your existing macro?

I feel like Alfred might be the answer, because it enables you to navigate to a folder and drill down into its sub-folders, then perform file actions.

This Alfred workflow gets pretttty close. You select one or multiple files in the finder, invoke the workflow, type the name of the folder you want to move it to and hit enter. That's all well and good, but if you drill down into a sub-folder, the workflow no longer moves the file(s). No cigar. It's based on AppleScript, so perhaps it could serve as the basis for something more useful to us...?

A different approach/mindset is go folder lite and tagging heavy.

Have a smallish base file structure and use Finder tags for the rest of the organization. A tagging/untagging palette is easy to setup. Tagging is more agile and easier than moving files.

Having a list of tagging groups in the Finder sidebar is fast and easy access.

It takes a bit to think in terms of tag sets vs folder sets. I’m gradually moving in that direction.

1 Like

Hey Guys,

I don't want to mess with this, but I have some suggestions.

  • You can't dynamically create a palette based on a file structure.
     
  • You can use AppleScript in a macro to update such a palette on demand. (Link)
    • Note – the linked macro doesn't do the job you want – it's just an example of how to create a macro with AppleScript.
       
  • Personally I'd probably do this job with a Prompt With List action rather than a palette.
    • You an easily create dynamic lists.
    • You can use one in a submacro and feed it different initial strings via a variable to produce different initial lists – then type a new search string if needed.
    • You can give list items tags to make finding like items easier.
    • Many things are possible.

-Chris

3 Likes

...meanwhile...

I've been over on the Alfred forum, researching options there. All I'll say about the experience so far is that I love the KM forum even more than I already did!

I don't want to speak too soon, but I may be very close to a nice solution for this, at least for me. The beauty of using Alfred is that it shows the actual folder hierarchy and never needs to be manually updated. Here's where I'm at:

image

The hotkey navigates to the parent directory of my collection of subfolders in Alfred's interface. From there, I can drill down to the desired destination folder before hitting the second hotkey. This runs a script that captures the path of the selection in Alfred's browser and moves the Finder selection to that location.

Here it is in action:

Move Script

Here is the osascript being used, which was sent to me by an Alfred forum user:

on run (argv)
	tell application "Finder"
		-- set destination from first command-line argument
		set _destination to POSIX file (first item of argv) as alias

		set _selected to selection as alias list
		move _selected to _destination
	end tell
end run

Issues:

  1. The script copies (rather than moves) the Finder selection when attempting to move between volumes. I'm pretty sure @ccstone will know why, as he kindly sent me a slightly different script yesterday that moves things perfectly.
  2. It opens the destination folder in a new Finder Window which may or may not be desireable.
  3. It involves two hotkeys. As far as I can tell, you can't pause a workflow until a key is down (Enter, for example), as you can with KM. You have to set them up as separate workflows that can be triggered with more hotkeys, or alternatively as "File Actions" to be manually selected from a dedicated menu.

I did try to think of a solution to this. It's a bit convoluted but hopefully makes sense:

Alfred:

image

KM:

The hotkey would firstly trigger a KM macro that pauses until the Enter key is down. After a very short delay, Alfred's browser navigates to the parent directory. The delay just ensures that the navigation triggers properly. After you have your desired destination folder selected, you would hit Enter, at which point KM would trigger the file-moving script in Alfred.

And of course, it doesn't work.

I think this may be because when you hit Enter it closes Alfred's file browser, so there is no longer a selected path for the script to reference.

The solution to this (and take this with a pinch of salt as a lot of this is slightly beyond my level of confident understanding) could be to have a looping script in KM that checks the current selected path in Alfred's browser and then runs the file-moving script based on the last one it sampled. Now, whether or not it's even possible to reference Alfred's browser selection from an external script would determine whether this is at all viable, and I'm flying blind there too.

Hopefully you can see that there's a nice and neat solution to this file sorting challenge that's almost within reach, and I'm sure that a veteran Alfred or KM user would be able to finesse it no time.

If only you could get Enter to trigger the script in Alfred, all of this would be a lot simpler!

1 Like

Another option.

@JMichaelTX put this together for me an age ago and it's still working. You select a file and trigger the macro and it calls up a regular Finder nav window. Go to where you want to move the file and click open and the file moves to the selected location.

Coupling this with Default Folder's Finder nav window enhancements and it's pretty easy to get around and move things around.

I've created a KM 'trigger file' for this macro which allows me to install it in the Finder windows toolbar.

You can also create a macro that adds or removes 'Favorite' folders to Default Folders Favorite lists that appears within the Finder nav window.

While not a dynamically updated list (the Default Folders Favorite list), it's about as easy a manual system as you're likely to get.

Actions (v10.0.1)

Keyboard Maestro Actions.kmactions (4.9 KB)

1 Like

Yet another option, which I think I might try using for the time-being. It's brutal but it works. It uses KM for everything except destination navigation, which is handled by Alfred. The only thing you need to set up in Alfred is a "Browse in Alfred" action with a hotkey. This will navigate to your parent directory in Alfred's browser, so change the hotkey in the respective KM action (marked out in green).

In use:

  • Select files to move.
  • Trigger KM macro.
  • Select destination folder.
  • Hit Enter to move the files or Escape to cancel.

Move Selection to....kmmacros (24.1 KB)

There's of course nothing wrong with using Alfred for selecting a folder destination if you prefer its interface, but if you're using KM for everything else already, I'm compelled to ask if you've tried @ccstone's suggestion to try Prompt with List, which can also be pointed to a parent folder and automatically updated with a list that shows the various subfolder paths, not to mention not requiring any Finder windows to be opened or closed:

Example Macro.kmmacros (3.3 KB)

Sample Prompt:

1 Like

I hear you but my folder structures are necessarily numerous and complex enough to make that a bit of a headache. I prefer being able to view folder structures as you would see them in the Finder itself, and be able to dive down two or three levels and only see the folders at that level... but I appreciate that may be peculiar to my own way of organising things.

The last macro I posted above is almost ideal for me; the only thing I don't like is that it requires a new finder window to open. I would prefer a script to perform the move discretely. But hey, it gets the job done.

My ambition to refine this into something slick was more that I thought other people might like to use it if it felt seamless. My scripting skills are basically non-existent (although I learn something via osmosis with every new adventure), so unfortunately I don't think I'll be able to achieve it with this.

I'd like to thank @ccstone again for his patience and expertise. The moving script he gave me recently that allows you to specify the destination by using Trigger Values from a Stream Deck is already finding a lot of uses.

I have no idea how I ever got any actual work done before I had KM. It's like a time machine. I turn it on and I get extra hours in the day!

1 Like

Because Apple is weird... ?

This has been true since a 40MB hard drive cost $250.00.

There is not even a good way to determine if/when the file system has finished copying an item. (Unless there's a method in AppleScriptObjC I haven't seen yet.)

This ought to be fairly safe:

--------------------------------------------------------
use AppleScript version "2.4" --» Yosemite or later
use framework "Foundation"
use scripting additions
--------------------------------------------------------

set destinationFolderPath to "/Volumes/Firestorm/• TEST_FOLDER/"
set itemToMovePath to "~/test_directory/AppleScript_Test/TEST ME.mp4"
set itemToMovePath to ((current application's NSString's stringWithString:itemToMovePath)'s stringByExpandingTildeInPath) as text

set destinationFolderAlias to POSIX file destinationFolderPath as alias
set itemToMoveAlias to POSIX file itemToMovePath as alias

tell application "Finder"
   move itemToMoveAlias to destinationFolderAlias
   delete itemToMoveAlias
end tell

--------------------------------------------------------

But I'd test it a few times with some big files, before I'd trust it.

-Chris

1 Like

I'm a bit baffled. That script includes references to specific locations and items* that don't exist on my system. How's that work?

(*I'm referring to TEST_FOLDER and TEST ME.mp4)

Hey Neil,

You're being too literal. Take a step back and broaden your perspective.

Those are just examples – you the user are expected to provide references to the necessary objects on your system.

The important part for you in view of what you're using already is the meat of the script – tell app "Finder"...

-Chris

Sorry Chris; I've become a bit spoiled by having things spoon-fed to me, haven't I.

I've got myself a bit confused now. The second Alfred shortcut isn't doing anything, so I'll append "delete _selected" to the osascript, figure out the shortcut issue and report back.

1 Like

Silly me. I'd upgraded my Alfred powerpack and had to allow all the permissions. It works now!

NB for anyone else who would like to use this method, because the script copies the files and then deletes the original (rather than moves it), undo works as follows:

Undo step 1: un-deletes the original.

Undo step 2: tries to move the copied file back to the original location, which will result in a dialogue asking if you want to replace the original. This is fine to do of course, but you may prefer to delete the copied version instead, if the file is large and would take time to copy back.