![coda for mac os x v.10.6.8 coda for mac os x v.10.6.8](https://brownrescue798.weebly.com/uploads/1/2/5/3/125320600/111976182.jpg)
To achieve both of these, refine the script above to look as follows, remembering to compile, save and test it (by moving something to the Trash, not from running in the Script Editor).įinally, with a bit of imagination and experimentation, you could add various other conditions to this script. In fact, it does so already (Folders are indicated by a colon), but it would perhaps be clearer and more orthodox if folders were followed by a forward slash, as they are usually indicated that way in path names. Also, it would be good if the file name actually indicated whether it was file or a folder that was being moved. DS_Store files to the Trash, and we don’t want to know about these. For one thing, every now and again OS X will move the. Everything OK? Hmm, maybe, but we need a few refinements. That’s pretty much it your TrashWatcher folder is set up, so move something to the Trash and make sure it fires. With the script saved in ~/Library/Scripts/Folder Action Scripts/, right click on any folder in a Finder window and choose ‘Services > Folder Action Setup’ from the contextual menu. If not, click ‘New Folder’ in the bottom left of the window, and create a ‘Folder Action Scripts’ folder (be sure to get the name exactly right). If there is already a folder called ‘Folder Action Scripts’ then save the script in there. In the resulting window, scroll down to the Scripts folder and look inside it. Do not click ‘Save’, but instead press, ‘Command-Shif-G’ on your keyboard and enter this location into the box that pops up:Īnd click ‘Go’. Give it a descriptive name like ‘TrashWatcher.scpt’ or similar. With Script editor still active, press ‘Command-S’ to bring up the ‘Save’ dialog box. We need to attach save the script in the right place first, and then attach it to the Trash folder. With the Script editor active, make sure your script compiles by pressing ‘Command-K’, but don’t try to run it yet. “View” opens the Trash folder in the event that you want to check or remove the items that have been added. Notice that “OK” (typically an action button) is used to dismiss or cancel the dialog. Note that the display dialog command adds a couple of buttons, and collects the result as to which button you pressed. Those five commands are all doing one thing: stripping the path from the item name down to just the item name itself so that we can display it nicely in the display dialog command that follows. This first determines how many items there are to be added and then iterates over them, applying the five ‘set’ commands on each file.
Coda for mac os x v.10.6.8 full#
The next line, declares an empty list, so that we can populate it later with just the names of the items, rather than their full path adddress. The first and last lines define a Folder actions handler, where the variables ‘this_folder’ and ‘added_items’ will be replaced by the name of the folder you attach this script too (we’ll do that in a minute), namely the Trash folder, and the items that have been moved to the Trash. Tell application "Finder" to open the trash Set a_file to text (stripTrashPath + 6) thru -1 of a_fileĭisplay dialog "The following items were moved to Trash: " & return & return & listOfFiles buttons with title "Trash Alert" with icon 0 Set stripTrashPath to offset of “Trash” in a_file Set a_file to item i of added_items as text Repeat with i from 1 to the count of added_items On adding folder items to this_folder after receiving added_items Start by opening the AppleScript editor (or Script Editor on 10.10), and paste the following lines into it:
![coda for mac os x v.10.6.8 coda for mac os x v.10.6.8](https://sg.canon/media/image/2019/01/24/3d99013811dd453faa22d44fd68861d9_G0189121.png)
It’s quick and easy to make, and you can customise it to do various other things apart from give a warning if you like (for example, you could make it delete files of a certain kind, size or date automatically). With that in mind, I created this little Trash Watcher utility to warn me anytime something is moved to the Trash. Fortunately, I noticed in both cases, and while I haven’t got to the bottom of the problem yet, I thought the first thing I’d better do is a bit of defensive scripting! The weird behaviour is that both times a whole load of my Xcode projects got moved to the Trash without my knowledge or permission. So twice in the last couple of weeks, I’ve found that something funny has been going on with Xcode, source control and Dropbox.