kyledempster7 Posted March 11, 2021 Posted March 11, 2021 Hello, I'm a softcore Alfred user. I love the app, but I get pretty confused with the coding. My problem is simple and has a lot of old broken results that seem to no longer work: I use Alfred to find folders on my Mac, but I go crazy when I have accidentally opened a dozen while creating podcasts and art. (maybe I need a better file structure) I'm hoping there is still a way to have Alfred merge Finder windows or at least run a script to open a bunch of windows and merge them all at once. Maybe I'll come up with more questions for this helpful community. Thank you!
deanishe Posted March 11, 2021 Posted March 11, 2021 Hi @kyledempster7, welcome to the forum. 5 hours ago, kyledempster7 said: I'm hoping there is still a way to have Alfred merge Finder windows or at least run a script to open a bunch of windows and merge them all at once. That's the wrong question, tbh. Alfred is a launcher: the only thing it can make other applications do is open things. Your question should be "how do I use macOS scripting to merge Finder windows?" Once you've figured that out, running the script via Alfred is simple. As such, this also isn't the best place to ask: some forum members are very good at application scripting, but we don't have the level of expertise you'll find on Ask Different or a dedicated macOS-scripting forum. To try to actually answer the question: I think your options are very limited. Finder's scripting API doesn't mention tabs, so I think you can only manipulate them by simulating keypresses and menu clicks. You could write a script to "click" the Window > Merge All Windows menu item. That seems somewhat pointless, though, as it's much simpler to assign it a keyboard shortcut in macOS System Preferences > Keyboard > Shortcuts > App Shortcuts. Or you could open multiple tabs in the same window by simulating ⌘T and then using AppleScript to change the folders the tabs are showing. (I think this is possible.) But as I said above, I'm no Finder-scripting expert. It's likely you'll get a better answer on Ask Different.
kyledempster7 Posted March 11, 2021 Author Posted March 11, 2021 I would disagree. I don't know much about scripting as I mentioned, I fear asking "how do I use macOS scripting to merge Finder windows?" would be above my skill set. As I mentioned above, I saw some people accomplish this idea in the past, but their documentation is two years old. I'll keep my fingers crossed someone here may know. Thanks anyways.
deanishe Posted March 11, 2021 Posted March 11, 2021 (edited) 1 hour ago, kyledempster7 said: I fear asking "how do I use macOS scripting to merge Finder windows?" would be above my skill set. Sorry, I wasn't clear. What I'm trying to say is that—assuming you're not expecting someone to provide you with a workflow that does exactly what you want—your question is really about Finder, not Alfred, because the only relevant thing Alfred brings to the table is the ability to run a script. That is to say, it's not so much a question of your skillset (you came here for help, after all), but of ours: We're the Alfred experts, not the Finder ones. 1 hour ago, kyledempster7 said: I saw some people accomplish this idea in the past, but their documentation is two years old You can't really judge code by its age. Software doesn't wear out, so changing things in a way that breaks old code is generally considered a pretty big deal. If the latest info/code/version you can find is a few years old, you can generally assume that's because it doesn't need updating. Edited March 11, 2021 by deanishe
dfay Posted March 12, 2021 Posted March 12, 2021 In any case here's the code (from the workflow linked above) - it's a pretty trivial bit of AppleScript - the function call is just there b/c I had it lying around. on alfred_script(q) click_menu("Finder", "Window", "Merge All Windows") end alfred_script on click_menu(app_name, menu_name, menu_item) try tell application app_name activate end tell tell application "System Events" tell process app_name tell menu bar 1 tell menu bar item menu_name tell menu menu_name click menu item menu_item end tell end tell end tell end tell end tell return true on error error_message return false end try end click_menu deanishe 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now