Jump to content

How do I open finder windows with finder tabs in Alfred?


Recommended Posts

I have a workflow that opens my regularly used finder windows: "hotkey + launch files." It opens 8 finder windows. The problem is that it opens 8 individual finder windows. This means I have to combine them into 2 separate finder windows with 4 tabs each. Is there a way to have Alfred open these finder windows as the 2 windows with 4 tabs?

Link to comment
13 hours ago, Undertaker01 said:

Is there a way to have Alfred open these finder windows as the 2 windows with 4 tabs?

 

This AppleScript will open each of the groups defined at the top of the script in a separate Finder window, with each path in its own tab.

 

-- each list in groups will be opened in tabs in the same window
property groups : {¬
	{"~", "~/Documents", "~/Downloads"}, ¬
	{"~/Library", "~/Library/Application Support/Alfred", "~/Desktop"}}

-- How long to wait (in seconds) between simulated keypresses.
-- Increase this value if the script works unreliably
property _delay : 0.25

use framework "Foundation"

-- expand ~ in path to home directory
on normalisePath(_path)
	set _string to stringWithString_(_path) of NSString of current application
	set _norm to stringByStandardizingPath of _string
	return (_norm as string)
end normalisePath

on run
	tell application "Finder"
		activate
		
		repeat with _paths in groups
			-- create new window to open tabs in
			make new Finder window
			--open folder "Documents" of home
			delay _delay
			
			-- for each path, open a new tab and navigate to the path
			repeat with _path in _paths
				set _path to my normalisePath(_path)
				-- log "path=" & _path & ", target=" & POSIX path of (target of front window as alias)
				
				-- simulate CMD+T to open a new tab
				tell application "System Events" to keystroke "t" using command down
				delay _delay
				set target of front window to (POSIX file _path as alias)
				delay _delay
			end repeat
			
			-- close initial tab
			tell application "System Events"
				keystroke tab using control down
				keystroke "w" using command down
			end tell
			delay _delay
		end repeat
	end tell
end run

 

Link to comment
  • 1 year later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...