Search code examples
applescript

Applescript: set folder as current folder


I'm trying to move a file to the current folder in Finder, with Applescript. The end result would be being in a specific folder in the Finder, hitting a shortcut on the keyboard, and having the file moved from the Downloads folder to the current folder.

I'm struggling to find a way to refer to the current folder, and to test this out in Applescript. Does anyone have any idea on the subject?

Thanks in advance!


Solution

  • The Finder has no notion of a "current folder". The folder that the user might be said to be "in" is the folder represented by the Finder's first window. You can experiment by saying:

    tell application "Finder"
        activate
        try
            get folder of window 1
        end try
    end tell