viernes, 6 de septiembre de 2019

Automate Task with Folder Actions



Turn on Folder Actions globally


To use Folder Actions, you must first turn this feature on globally. To do this, right-click or Control-click on any folder and choose Services -> Folder Actions Setup. (If you only have a few Services, you may not have a Services menu and will instead see the Folder Actions Setup menu item at the bottom of the contextual menu.) When you choose Folder Actions Setup, a small window opens showing a list of AppleScripts. Select Enable Folder Actions in the window and then quit (Command-Q).

Get alerted to incoming files


Now, let’s apply a simple, useful folder action to one of your folders. If you share files with others over a network, your colleagues may deposit files in your Mac's built-in Drop Box folder. But how do you know when a new document has arrived? Add a Folder Action that displays a dialog box whenever a new file is added to this folder.
To do this, first go to your Public folder. You’ll find it inside your home folder—the one with the house icon. (Or, in the Finder select Go -> Go To Folder and type ~/Public/). Right-click or Control-click on the Drop Box folder inside, choose Folder Actions Setup, click on “add - new item alert.scpt,” and then click on Attach.


Let’s try this out. Take any file and place it inside this folder. Within a few seconds you should see a dialog box telling you how many new items were added to the folder. This dialog asks if you would like to view these items. Click on Yes to open a window showing the files, or click on No to dismiss the dialog box. You may not need to see the files right away, but now you know that they have been added.


Once you attach the Folder Action to your Drop Box folder, you'll see an alert like this every time someone puts something in the folder.



Another way to use this same script is with your Dropbox folder. If you share files using Dropbox’s shared folders, you may want to know when you receive new files. Dropbox offers “desktop notifications”—floating alerts—but they fade away after a few seconds. Attach the same script we used above to a shared folder and you’ll see an alert whenever Dropbox downloads new files to that folder. Note that this only works when an item is added to the folder itself, not when someone adds an item to one of its sub-folders. If you have a lot of sub-folders in your shared folder, you can apply the same script to each of them to get alerts for all of the folders.

Explore OS X’s other built-in actions


OS X includes a handful of folder action scripts in the /Library/Scripts/Folder Action Scripts folder. Let’s look at a couple of them and see how they can save you time.

In this folder, you’ll see a number of scripts that can act on graphics. For example, there are three scripts that can automatically convert image files to JPEG, PNG or TIFF format. Let’s say you have a blog, and you want all your graphics to be in JPEG format. Create a folder somewhere and attach the “image - Duplicate as JPEG.scpt” script to it. Every time you add an image file to that folder, it will be immediately converted.

There’s a nifty script if you often open a lot of folders within a specific folder. As you know, closing all those windows can be annoying. If you attach the “close - close sub-folders.scpt” script to a folder, any sub-folders that are open will be closed when you close the top-level folder. This is useful if you have projects that require you to access files in a lot of sub-folders.

Turn off Folder Actions


If you ever want to turn off Folder Actions for specific folders, you can access the Folder Actions Setup applet as described above by clicking on any folder. Dismiss the list of scripts, and you’ll see a list of those folders for which you’ve set Folder Actions, and which scripts you’ve attached to them. Turn off any of these by unchecking them, or delete any folder or script by selecting it and clicking on the minus button.



In this window, you can see all folders that have Folder Actions attached to them, and which scripts they are set to run.







source: www.macworld.com

No hay comentarios:

Publicar un comentario