I want to create a script that takes the current file selection and moves it to an already existing folder. I will then duplicate this code for 9 other folders and assign them all keyboard shortcuts.

My application is rather specific and unfortunately I need to use Finder to quickly monitor audio samples rather the Terminal. (I am wading thru thousands of audio samples, deleting and sorting them into sub folders).

The idea is very simple:

tell application "Finder"
    move selection to alias "Users:Jordan:Desktop:0"
end tell

This code works; however, it then proceeds to move the parent folder of the target file into the destination folder. This action makes the script counterproductive and useless. I tried the same idea in automator to no avail either. I have made long scripts to try and stop the tell from moving the folder too, but nothing has worked.

It's beyond me why such a simple function can be so buggy and difficult and why no matter how many variables I employee to make the selection static, or how many conditionals or delays I add, the script still moves the file in folder A to folder B THEN the folder A into folder B.

How do I move file in folder A into folder B without moving folder A into it as well?

  • Thanks for the replies. I tried all 3 suggestions, but to no avail. Some work in automator with play button. However, they fail as shortcuts. The Finder section in the top nav flashes like the service is executed, but nothing happens. I took a screenshot of what I have, but am not sure if I can even upload a photo to this site. It would save a lot of words... May 16 '15 at 1:32

This might be a bit of a sledgehammer approach by Applescript compared to Automator's 'move' command, but as that's how the OP approaches it...

To do it as an Automator Service, so it's easy to hotkey it…

'Service receives selected 'files or folders' in 'Finder''.

on run {input, parameters}   

    tell application "Finder"
        set selected_items to selection
        set theFolder to ((((path to desktop folder) as text) & "test") as alias)
        repeat with x in selected_items
            move x to theFolder
        end repeat      
    end tell    

    return input
end run

Actually I would use Automator.

Set up a service and call it what you like.

Under the "Actions" tab select "Files & Folders". Then double-click/select "Move Finder Items".

Then select the location you want said items to move to. Save it and then you can add it to the custom keyboard shortcuts.

To do this go to "System Preferences" and under "Keyboard" select "App Shortcuts". Next click the "+" sign and add in the name that your automator app was saved as.

Then try it out!

  • one sec i dont know if you edited post of i misread
    – les
    May 13 '15 at 7:09

i know this is old, but i´m doing this with these few lines of code:

tell application "Finder"
    move selection to folder ((path to home folder as string) & "Dropbox:Folder 01")
end tell

It works with single and multiple files.

  • I‘ve removed the follow-up question in your answer. Please ask a new question using the Ask Question link.
    – nohillside
    Apr 30 '19 at 21:02
tell application "Finder"
    repeat with thisFolder in (items of (get selection))
        repeat with thisItem in (get items of thisFolder)
            move thisItem to (POSIX file "/Users/Jordan/Desktop/0/")
        end repeat
    end repeat
end tell 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .