Friday, July 15, 2011

Exploring the Uses and Users of AppleScript

As a flexible, inter-application scripting language, AppleScript has a virtually unlimited number of uses and can be used by every user of a Mac computer. Even though many users will not take the time to learn the language and write their own scripts, they can still use the scripts written by others.
Tip 
Always use caution when using scripts written by someone else. Be sure they are reputable or have a personal connection to you. A script could potentially perform malicious or virus-like behavior.
Scripts can react to various stimuli. Double-clicking a script application can begin an automated process while another application begins processing files a user drops on it. Scripts can be attached to the script menu, embedded into application menus and palettes, and on a Finder window toolbar. They can be launched by an iCal alarm or whenever files or folders appear in a watched folder. Scripts can talk to other scripts on a user's computer or other computers across the office or the Internet. Scripts can run day and night, constantly watching, checking, processing, and reporting on anything that anyone takes the time to develop.



Uses for AppleScript

While some scripts may possess wider appeal and mass-market usefulness, typically most focus on a specific company's unique workflow. They can integrate third-party applications in ways that would not be practical or economical for mass production. Every manual task performed on a Mac computer can be automated with AppleScript, leaving its limitations to that of your imagination.
The following examples provide a glimpse of the limitless activities that can be automated with AppleScript.

File Processing

There are numerous ways to streamline user interaction with files:
  • Image files can be opened, resized, flattened, modified with filters, and saved into one or more new files. A script can automatically create preview images for the Web and high-resolution files for print. It can make "decisions" and vary the processing tasks based on a characteristic of the file, such as the file name, layer names, size, or page orientation. Individual files can be merged into a preview sheet or split into separate files. Any of these tasks can be automatically performed on a folder of 10 images or 10,000.
  • PDF files can be manipulated with AppleScript to suit the needs of even the most complex workflow. Scripts can add or remove pages, stamps, comments, and more. Separate files can be merged into a single file while multiple page files can be split into individual files. A script can generate PDFs, print them, and place them in a folder for human review. The content of the files can be resumes, books, instruction manuals, fact sheets, and countless others. A script can detect and process each with a separate set of business logic.
  • Scripts can manipulate text-based data files of any type. They can change delimiters to comma, tab, or fixed width text. They can extract specific rows or columns based on date ranges, product numbers, or customer name and then generate a new file with only the desired information. The files can be resorted, have data added or removed, and can be checked for common errors. Characters can be replaced with other characters to conform to importing regulations of databases, hypertext markup language (HTML) language rules or your company business rules.

E-Mail Processing

On an automated e-mail account or a user's computer, AppleScript can help manage a crowded inbox and assist in sending bulk e-mail:
  • Scripts can scan, read, and take predetermined actions on incoming messages in many popular e-mail applications. They can also help you prepare, create, and customize messages to a batch of contacts.
  • Scripts can detect, read, parse, and route data from a Web form to a database. On a user's computer, this can be done with a mail rule that runs an AppleScript when Mail detects a web form email. A server with a fully autonomous script and dedicated e-mail account can constantly monitor the inbox for various messages from different Web forms. Once an incoming message has been processed, an alert can be sent to key personnel notifying them of the new information.
  • Scripts can help send e-mail, especially in batches. Sending a single e-mail message to a huge list can be less impersonal by a script that sends a separate e-mail to each person on a list with a personalized greeting. Scripts can even build a unique e-mail based on customer ordering patterns, available material, and encoded business rules that describe how the recipient and the personal message should be matched up.

Desktop Publishing Automation

Using scripts to automate laborious desktop publishing tasks could fill endless volumes. Scripts can build simple pages with a variety of styles or build complex pages with hundreds or thousands of specific business rules encoded. They can build catalogs, complex tables, and charts, and automatically import text and images from various sources. They do all of this while reducing errors, improving consistency, and flawlessly enforcing style guidelines. In addition:
  • Scripts can build catalog files of any type. Even a catalog with uniform styling and formatting can be a burdensome task to build by hand. A user must copy, paste, position, and style text, then search for and import the appropriate artwork or images. When catalog pages vary by category or product data, scripts eliminate the need to remember numerous layout design rules. They can quickly and accurately locate the text and images necessary to build richly styled and dynamically spaced product information into a copy of the appropriate template. Watching for changes in category or other group fields, a script can diverge the styles and structure based on the appropriate rules. For example, each product category could require the insertion of a title page with a leading blank page or it might prompt the creation of an entire new document for each section.
  • Scripts can scan documents and build indexes or tables of contents. They can cross-reference products across corresponding documents, such as a catalog that has a separate price book.
Some processes are too daunting to contemplate without scripts, such as modifying hundreds of price changes or adding or removing products. Instead of manually updating pricing and squeezing new products into spaces left by old ones, a script enables you to simply build an entirely new catalog.
Monitoring sales performance of a catalog or other advertisement can be difficult when simply looking at the numbers. The context of the sale — such as the page the customer was reading when ordering — can be just as important to determine which strategies are working and which are not. A script can open documents, color-code product information based on actual sales, expand the page size, and integrate key sales data right on the page. Imagine the advantage of not just knowing how well a product did but also why it did so well when placed in a certain location on a page.

Central Processing and Resource Monitoring

Even as a script saves you time, it might be wasting it. Rather than sitting idle, mesmerized as you watch a script take control of the applications on your computer, you might consider setting up an automation server. Just as a file server, mail server, or Web server centrally processes information for its respective services, an automation server is a shared computer on a network that centrally processes all of your automated activity.
Tip 
A Windows-based company can still benefit from AppleScript automation with a single Mac acting as an automation server. All of the scripts process incoming files and then push them back out to the users. This can even be a great way to help convince management to consider a full switch to Mac OS X.
Instructions can be sent to an automation server is many different ways. The most common is to simply move files for processing into folders that are being watched by a script. When a new file appears, the script "wakes up" and begins processing them. Likewise, users might indicate through a database or a small custom script which catalog they want to build. The script would receive these instructions and begin the process. With an automation server watching folders, multiple users can send files dozens or hundreds of files at the same time. They are queued up in the watched folder and are processed while users work on other tasks, go to lunch, or leave for the day. The scripts keep on working.
Scripts that monitor valuable resources and ensure that key systems are up and running are best suited when they are running on an automation server. For example:
  • Scripts can search, sort, and extract data from databases and then create and send periodic e-mail reports to key personnel. A script can send a daily sales report, tabulated survey data, a summary of sales leads, and any other kind of report you can generate manually. This saves users the time it takes to locate, open, and create a report query, and a report can even be generated early in the morning before the staff arrives.
  • A script can scan a file server to ensure that folder structure rules are being followed. If misfiled items are detected, it might send an e-mail alert listing the offending items and can even include a URL link so the reader can quickly navigate to the item to remedy the situation. It might send one e-mail to graphic artists informing them that images are supposed to be in a subfolder called Product Images and another to the sales team indicating that spreadsheets need to be in the Reports folder. Managers can be CC'd on these, notifying them of issues and empowering them when they need to enforce compliance.

Users of AppleScript

While the AppleScript language is designed to be accessible for casual programmers of varying skill level to write scripts, it can be used by anyone. Scripts built with AppleScript can dramatically increase a user's productivity while simultaneously reducing stress and errors and increasing adherence to business rules Scripts free up users to focus on details that cannot be automated and require human attention.

Individuals

Whether an employee works for a small, family-owned business or a Fortune 500 corporation, he can use AppleScript solutions to streamline any repetitive task. Any task, large or small, involving at least some repetition can typically benefit from automation. These custom tools can be built to help remind, assist, and notify this employee with his daily work.

Teams

As part of a team, individuals need to focus not only on their work but also keep in mind how their work integrates with their co-workers and the goals of the team. When each member of the group has access to a well-designed set of tools that helps her get her work done quickly while adhering to company policy, the team will benefit enormously. Scripts can help team members navigate project folders; store files in the correct location, with approved naming conventions; and notify others about their status. Scripts can remove much of the stressful and redundant tasks that can sap the creative effort a team needs to thrive. An overworked team might rejoice over more work as long as they have the tools necessary to get it done.

Companies

The breadth of a scripted solution has no limitations. As long as it is worth the development effort required, automation can provide solutions to individuals, teams, divisions, and more. Any and every department within a company can benefit by automation. Whether it is sales, marketing, design, inventory, shipping, or any other department, AppleScript provides a powerfully scalable technology that can be a solution to almost every repetitive problem you can imagine, regardless of the industry. Scripts enable companies to improve the quality and quantity of work while reducing costs, errors, and stress, leaving in their wake an environment conducive to creative thought.

No comments: