Jump to content
ehrlund

Go To Path in Open/Save Dialogue

Recommended Posts

Hey,

 

I've been trying to convert this launchbar script into an Alfred Workflow. The script is meant to take the current selection of Alfred, and activate the window behind, open the "Go To Folder" dialogue, paste in the path and press enter. 

 

I got it working in the AppleScript Editor, but for some reason I can't get it to perform on through Alfred. It even opens up the "Go To Folder" dialogue but stops there each time. Do you guys have any ideas?

 

 

on alfred_script(q)
	
	set filePath to POSIX file of q
	
	tell application "System Events"
		set theApplication to application processes whose frontmost is true
		set target to item 1 of theApplication
		set target to a reference to front window of target
		set target to a reference to front sheet of target
		delay 0.5
		tell target to keystroke "g" using {command down, shift down} -- Activate goto field
		tell target
			try
				set value of text field 1 to filePath
				delay 0.5
				key code 36 -- simulate pressing the Enter key
			end try
		end tell
	end tell
	
end alfred_script

 

 

 

Share this post


Link to post

OK. I made a workflow and tested it only with AppleScript Editor. Here is the code that worked:

 

—-The save as dialog uses text as input and UNIX path as far as I can tell
set filePath to POSIX path of q as text

tell application "System Events"
	set theApplication to application processes whose frontmost is true
	set target to item 1 of theApplication
	set target to a reference to front window of target
	set target to a reference to front sheet of target
	delay 0.5
	tell target to keystroke "g" using {command down, shift down} -- Activate goto field
	delay 0.5
	tell target
		set value of text field 1 to filePath
		delay 0.5
		key code 36 -- simulate pressing the Enter key
	end tell
end tell

 

I removed the “try” part of the code to better debug it… Your final code of course may add them back.

 

Finally, you can write AppleScript directly using Language "/usr/bin/osascript”.

Edited by Carlos-Sz

Share this post


Link to post

Was anyone able to make a working workflow they could share? I've been scratching my head trying to get the correct combination of events.

 

Just wondering, is it possible to drill down to a location using Alfred's system browser then change the location in the dialog box?

 

Thanks

Edited by ZeroFill

Share this post


Link to post

Was anyone able to make a working workflow they could share? I've been scratching my head trying to get the correct combination of events.

 

Just wondering, is it possible to drill down to a location using Alfred's system browser then change the location in the dialog box?

 

Thanks

 

I’ve added similar feature but with a different approach in two of my workflows (the first one is also a feature in the second one):

 

Default Folder

 

Recent Finder Items

Share this post


Link to post

Was anyone able to make a working workflow they could share? I've been scratching my head trying to get the correct combination of events.

 

Just wondering, is it possible to drill down to a location using Alfred's system browser then change the location in the dialog box?

 

Thanks

 

@Carlos-Sz : Nice work! Good demonstration of many ways with which this can be done with Alfred.

 

@<others> :)

 

I know its an old thread. But I also came here looking for this and I believe so will others. A simple File Action is what is called for.

I possess no special workflow skills, but still, I am posting the solution for those who cannot create this workflow:

 

https://www.dropbox.com/s/55534rd0c5wpxhl/open_save_dialog.alfredworkflow?dl=0

 

How to use?

Bring up any file/folder in Alfred

type your shortuct for action Action

and run this workflow which is currently named "Send To Open or Save dialog".

 

I personally believe (and I have nothing against what anyone else's approach is):

1. Alfred's File Search is neatly organised.

2. Single quote easily gets me to the folder/file I need to.

3. There is no need to over-complicate things by adding new keywords and then performing actions to get to the item which you could have easily got to by typing single quote in the first place. The more the keywords, the more the complications (naming pattern, length etc) in using them.

4. When 2 shall not remain true, then and only then, create Favorites folder, otherwise you are slowing yourself down instead of doing things quickly.

 

 

Thanks.

Edited by rounak

Share this post


Link to post
On 9/5/2016 at 0:08 AM, rounak said:

 

@Carlos-Sz : Nice work! Good demonstration of many ways with which this can be done with Alfred.

 

@<others> :)

 

I know its an old thread. But I also came here looking for this and I believe so will others. A simple File Action is what is called for.

I possess no special workflow skills, but still, I am posting the solution for those who cannot create this workflow:

 

https://www.dropbox.com/s/55534rd0c5wpxhl/open_save_dialog.alfredworkflow?dl=0

 

How to use?

Bring up any file/folder in Alfred

type your shortuct for action Action

and run this workflow which is currently named "Send To Open or Save dialog".

 

I personally believe (and I have nothing against what anyone else's approach is):

1. Alfred's File Search is neatly organised.

2. Single quote easily gets me to the folder/file I need to.

3. There is no need to over-complicate things by adding new keywords and then performing actions to get to the item which you could have easily got to by typing single quote in the first place. The more the keywords, the more the complications (naming pattern, length etc) in using them.

4. When 2 shall not remain true, then and only then, create Favorites folder, otherwise you are slowing yourself down instead of doing things quickly.

 

 

Thanks.

Any chance of a fix to the DropBox link?

 

Share this post


Link to post

Hello dreamers.

For anyone coming here still looking for this, so was I, and I managed to create something which does exactly what I want.

 

Here it is:

https://drive.google.com/file/d/1NQyB4u58QWxC8BR-9VgBmy2MEioGuQ2m/view?usp=sharing

 

It has two triggers. 

Either you search for a file the normal way (pressing space), then action it and pick "Paste path into dialog box"

or

You start a custom file search using "p", then just press enter when you've found your file/folder and voila.

 

Hope this helps someone!

 

Love

Paul

 

makesmefeel.com

Edited by oldflattop

Share this post


Link to post

Thanks oldflattop!

My previous 'Go To Here' workflow stops working after Alfred 4 upgrade. This one work great! 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...