Need some Help? Have a tip to share?

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

MacTipper Recommends Dropbox!


Dropbox is by far the most useful app I have ever had the pleasure of owning. Best of all, it's free! Check it out here!

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]

26 comments:

  1. Whats the difference between using the script and using drag when command down?
    ReplyDelete
  2. Drag and drop requires that you use the mouse. The script allows you to stick to the keyboard.
    ReplyDelete
  3. Amazing. I love you, dude!
    ReplyDelete
  4. I have been trying to do this . and used the applescript .
    ReplyDelete
  5. Hi,

    what do I do if I want to uninstall it?
    ReplyDelete
  6. Go to (Your home folder)/Library/Services/ and delete the "CutFileInFinder.service" file.
    ReplyDelete
  7. 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
    ReplyDelete
  8. the bar of says "moving &&& to &&& " but it just copies...
    ReplyDelete
  9. 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.
    ReplyDelete
  10. 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.. ;-)
    ReplyDelete
  11. 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
    ReplyDelete
  12. 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.
    ReplyDelete
  13. so this app's name should be "Copy/Paste in Finder.app" ???

    i am confused...
    ReplyDelete
  14. 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.
    ReplyDelete
  15. 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.
    ReplyDelete
  16. Thank you for this amazing and simpler solution!
    ReplyDelete
  17. 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!
    ReplyDelete
  18. 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
    ReplyDelete
  19. it doesnt work on snow leopard 10.6.1
    ReplyDelete
  20. This thing does not work on 10.6.3. Any chance of update?
    ReplyDelete
  21. No love for 10.6.3 here either. Please hook us up man!
    ReplyDelete
  22. 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
    ReplyDelete
  23. You can use moveAddict to cut and paste files, a new Snow Leopard-only application.

    You can find it at http://kapeli.com
    ReplyDelete
  24. Yeah, Kapeli does the trick in Snow Leopard, wicked!
    ReplyDelete
  25. How about this:

    tell application "Finder" to move selection to choose folder

    I think this one line does everything you're looking for, or did I get something wrong?
    It works like this:
    - You select a file in the Finder.
    - You press the shortcut for this service.
    - You choose the destination folder and press return.

    It worked well when I tested it. I'm using Snow Leopard.
    ReplyDelete
  26. The line I posted yesterday doesn't work with single folders selected in column view. But this seems to work:

    tell application "Finder"
    if selection is not {} then
    move selection to choose folder
    else if Finder window 1 exists then
    if insertion location is target of Finder window 1 then
    set aFolder to target of Finder window 1
    move aFolder to choose folder
    end if
    end if
    end tell

    Enter this in Automator as a service and choose "no input" and "Finder".
    Btw, the shortcut cmd-x doesn't seem to work in Finder. I chose cmd-alt-x.
    ReplyDelete

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

Subscribe Via Email!

Enter your email address:

Delivered by FeedBurner