AppleScripts for Finder

I found recently this amazing Mac application called Spark that allows you to define global shortcuts keys (hotkeys). Here are some utility scripts I conjured to make my life easier.

Copy the current Finder path to the clipboard.

tell application "Finder"
	set theWindow to window 1
	set thePath to (POSIX path of (target of theWindow as alias))
	set the clipboard to thePath
end tell

Open an iTerm in the current Finder location.

tell application "Finder"
	if ((count the window) < 1) then
		return
	end if
	set theWindow to window 1
	set thePath to (POSIX path of (target of theWindow as alias))
	my openTerminal(thePath)
end tell

on openTerminal(path)
	tell application "iTerm"
		activate
		if not (exists current terminal) then
			launch session "Default Session"
		end if
		set mysession to current session of current terminal
		select mysession
		set cmd to "pushd " & path
		write mysession text cmd
	end tell
end openTerminal