Frequent question pt 2

In my last post I explained how to get the path of the current window to your pasteboard, now it’s time to do something with that path you have in your pasteboard.

Imagine you have a colleague who’s using our little script to get his path, he now sends it to you so you can open the folder he’s refering to, do the same procedure as last time (create an app of the script below, and drag to your finder toolbar). You press the app, and you are presented with an input, enter the path your mate sent you and presto, you will get a new finder window of that location.

try
	tell application "Finder"
		activate
		set current_path to (the target of the front window) as alias
		set current_path_posix to the POSIX path of current_path as string

		set temp to display dialog "Enter Path" default answer current_path_posix
		set new_location to the text returned of temp

		set macPath to POSIX file new_location as Unicode text

		open macPath

	end tell
end try

This example fills the input dialog with the location of the current folder, this could easily be changed to default contain the content of your clipboard, making the example workflow I mentioned even faster.

Categories