Move newest file in Downloads folder to the frontmost Finder window

Here's what you do:

  1. Open the folder where you want to move your newest download in Finder.
  2. Trigger the shell script below.

The file will magically be moved! You'll even get a Notification Center notification.

The shell script

Triggering the shell script

I use an AppleScript saved as a .app and triggered with LaunchBar. Here's the AppleScript:

do shell script "bash /Users/YOUR_USERNAME/path/to/script.sh"

AppleScript: Save Clipboard to Text File

This AppleScript will open a "Save as" dialog, which lets you specify a folder and filename, using the folder of the front-most Finder window as the default folder. It will then save the (text) contents of your clipboard to that .txt file.

tell application "Finder"
	if (count of windows) > 0 then
		set theDefault to the POSIX path of ((folder of window 1) as alias)
	else
		set theDefault to path to desktop
	end if
end tell

set resultFile to (choose file name with prompt "Save As File" default name "paste.txt" default location theDefault) as text
if resultFile does not end with ".txt" then set resultFile to resultFile & ".txt"
set resultFilePosix to quoted form of the POSIX path of resultFile
do shell script "pbpaste > " & resultFilePosix