Need some Help? Have a tip to share?

Email me at MacTipper@gmail.com, or, leave a comment!

Learn How to Win Free Stuff Online


9/18/08

Cut/Paste in Finder.app

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]

23 comments:

Anonymous said...

Whats the difference between using the script and using drag when command down?

MacTipper said...

Drag and drop requires that you use the mouse. The script allows you to stick to the keyboard.

dpiv said...

Amazing. I love you, dude!

MacPhobia said...

I have been trying to do this . and used the applescript .

Anonymous said...

Hi,

what do I do if I want to uninstall it?

MacTipper said...

Go to (Your home folder)/Library/Services/ and delete the "CutFileInFinder.service" file.

Anonymous said...

Hi,
doesn't work for me when i cut paste from one hard drive to another. it just copies.
It works fine to cut paste in the same harddrive though

Please help

Anonymous said...

the bar of says "moving &&& to &&& " but it just copies...

MacTipper said...

Unfortunately, that is because Finder always copies files from one HD to another. The only solution is to move the file with the mouse. When moving with the mouse, hold the Command key so that the cursor changes from a plus cursor to a normal cursor.

Anonymous said...

The click here to download installer app link has some pretty horrible shit at MediaFire.com. I would ditch them dude.. seems like they have sold out to the devil. Popups and drive by installs are their flavor. I don't like your taste. Good App.. maybe loose MediaFire. Dubious to say the least. Otherwise.. good work! I am going to tackle copy and paste in OS X as well.. but i wish apple would just include it already. It is seriously a flaw in their OS. Many mac users just don't get how good cut and paste is. Drag and drop has it's place but it's for pansies.. ;-)

Anonymous said...

i won't cut and paste, it just copy and paste
the original file won't be deleted.

I am right that i should use "Cmd+X" to cut and "Cmd+X" to paste???

anyway, nice try, thx

MacTipper said...

Yes, that is correct. Cmd-X is used to cut the file and paste the file. (It is independent of the Cmd-C/V that is built in.) Until Apple can provide this to us, this is the best I've come up with so far.

Anonymous said...

so this app's name should be "Copy/Paste in Finder.app" ???

i am confused...

MacTipper said...

When you install the service and set up a keyboard shortcut, you can move files using that keyboard shortcut.

When you first activate the service, it finds out where the file you selected is. Then, when you activate the service again, it moves the file to the currently viewed folder.

Copy and paste keeps the original file.

sega said...

although your work is truly highly appreciated, but it just won't work....

it works ONLY within the same harddisk, but NOT between two harddisks.

Anonymous said...

Thank you for this amazing and simpler solution!

Anonymous said...

How do I remove this script from 10.6.3. It doesnt seem to be what im after. I know this is a small thing but for an ex-windows user this sucks. How can a simple core function be so hard!? Otherwise Im loving the MAC so far. But jeez!

Bill Yates said...

2010 and we cant cut and paste on a computer!? and its been an issue for years and STILL not resolved. WT.......... come on Apple

Anonymous said...

it doesnt work on snow leopard 10.6.1

Anonymous said...

This thing does not work on 10.6.3. Any chance of update?

Anonymous said...

No love for 10.6.3 here either. Please hook us up man!

Oliver said...

I cannot figure out why the Service is not working, it appears that services built by ThisService do not work in Snow Leopard. (Which is a pain because I use a lot of custom services.)

That aside, this applescript combined with your favorite applescript executor (mine by Spark), you can get back cut functionality:



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

Kapeli said...

You can use moveAddict to cut and paste files, a new Snow Leopard-only application.

You can find it at http://kapeli.com

Post a Comment

Subscribe Via Email!

Enter your email address:

Delivered by FeedBurner