Update
Snow Leopard broke the Service. Here's an applescript that should do the trick. Just combine it with your favorite keyboard macro program:try
((((path to home folder) & "Library:Application Support:Finder.Cut:file_paths.txt") as string) as alias)
set AppleScript's text item delimiters to (return as string)
set the_file_list to every text item of (do shell script "cat ~/Library/\"Application Support\"/Finder.Cut/file_paths.txt")
set AppleScript's text item delimiters to ""
tell application "Finder"
try
set front_window to (folder of the front window as string)
on error
set front_window to (path to desktop folder as string)
end try
log front_window
end tell
set paste_error to 0
repeat with each_item in the_file_list
try
tell application "Finder" to move (each_item as alias) to folder (front_window as alias)
on error
tell application "Finder" to display dialog ("A file called \"" & (name of (info for (each_item as alias)) as string) & "\" already exists.")
set paste_error to 1
end try
end repeat
if paste_error is 0 then
do shell script ("mkdir -p ~/Library/\"Application Support\"/Finder.Cut/; rm -f ~/Library/\"Application Support\"/Finder.Cut/file_paths.txt")
end if
on error
do shell script ("mkdir -p ~/Library/\"Application Support\"/Finder.Cut/; rm -f ~/Library/\"Application Support\"/Finder.Cut/file_paths.txt")
tell application "Finder" to set the_selected_items to the selection
repeat with a_file in the_selected_items
set the_path to quoted form of ((a_file as alias) as string)
do shell script ("echo " & the_path & " >> ~/Library/\"Application Support\"/Finder.Cut/file_paths.txt")
end repeat
end try
Something that drives me crazy about Finder is that there's no Cut function. That is, you can't select a file, hit Cmd-X, then go to another window and hit Cmd-V to move the file to the other window. You can do copy/paste, but then you have to go back and delete the original file. Also, you could just drag it with the mouse, but I would rather keep my hands on the keyboard.
I've written an applescript (used as a Service) to solve this problem. Unfortunately, there are a few caveats to my service:
You need to use the same keyboard shortcut for Cut and Paste. (I used Cmd-X, but you can use whatever you want as long as it already isn't in use.)
Pasting to the desktop has problems. (If you click on the desktop to make it the active window, it will paste into any window's you have open. However, this is easily fixed by hitting Cmd-Shift-D then Cmd-X to paste.)
It's not true Cut and Paste. (Because of the way that the applescript works, you need to paste something before you can cut again. Also, the file isn't moved to the new location until you paste. In addition, you can't paste the same file into multiple locations.)
If these relatively minor problems are fine with you, then read on for how you too can get Cut/Paste in Finder!
I've written an installer to make it easy to install the script. The install will copy the file to the appropriate location in your Home folder and add Cmd-X as the keyboard shortcut. To use the installer, download it, then unzip the file and run the application. You should here a notification sound and you're all set. To get the keyboard shortcut working, you will need to restart Finder. To do this, hit Cmd-Option-Escape, select Finder, then select "Relaunch".
Click here to download the Service Installer.
If you're curious to see the script file, you can download that also.
Click here to download the raw script file.
[Source Script Download Link]
[Service Installer Download Link]
MacTipper Recommends Dropbox!

9/18/08
Cut/Paste in Finder.app
Posted by
Oliver
at
Thursday, September 18, 2008
Labels: AppleScript, Application, Services Menu
Subscribe to:
Post Comments (Atom)

26 comments:
Note: Only a member of this blog may post a comment.