You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript to mimic behavior of folder on desktop

I am unfortunately a complete novice with Applescript. I would like to write a script that mimics the behavior of a folder icon in the Finder. So that if I save it as a compiled app:

(1) if I drag a file to the app, it moves the file into a folder pre-specified in the script (call it "~/Desktop/My\ Folder") and

(2) if I just double-click on the app, it just opens that folder in Finder.


My attempts to create something, modeled on scripts I see online, are not working out. Would very much appreciate help — thank you!!


(Invoking Automator would also be fine.)

MacBook Pro

Posted on Oct 12, 2019 10:24 AM

Reply
Question marked as Top-ranking reply

Posted on Oct 14, 2019 12:31 PM

This is pretty straightforward.


Save the following script as an application. Turn off the 'Show startup screen' option in the Save dialog


You need to change the 'property destFolder...' line to the path to the directory you want to target.


use AppleScript version "2.4" -- Yosemite (10.10) or later

use scripting additions


property destFolder : "Macintosh HD:Users:you:folder name" -- edit this!


on run

-- Executed when the app is double-clicked:

tell application "Finder" to open folder destFolder

end run


on open of theFiles

-- Executed when files are dropped on the script:

repeat with aFile in theFiles

tell application "Finder"

move aFile to folder destFolder

end tell

end repeat

end open

Similar questions

2 replies
Question marked as Top-ranking reply

Oct 14, 2019 12:31 PM in response to dpdpdp

This is pretty straightforward.


Save the following script as an application. Turn off the 'Show startup screen' option in the Save dialog


You need to change the 'property destFolder...' line to the path to the directory you want to target.


use AppleScript version "2.4" -- Yosemite (10.10) or later

use scripting additions


property destFolder : "Macintosh HD:Users:you:folder name" -- edit this!


on run

-- Executed when the app is double-clicked:

tell application "Finder" to open folder destFolder

end run


on open of theFiles

-- Executed when files are dropped on the script:

repeat with aFile in theFiles

tell application "Finder"

move aFile to folder destFolder

end tell

end repeat

end open

Applescript to mimic behavior of folder on desktop

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.