Section A.1. The Problem

A.1. The Problem

I have just completed, working in Adobe FrameMaker , the manuscript for a book about AppleScript. This manuscript is now to be submitted to my publisher. My publisher can take submissions in FrameMaker, which is what the production department uses in-house, and there is a checklist enumerating certain details of the form the manuscript should take. Looking over this checklist, I find an entry from the illustration department informing me that I'm supposed to follow certain rules about the naming of the files that contain the illustrations, and that I'm to submit a list of illustrations providing the number, name, and caption of each figure. Table A-1 presents the example the illustration department provides.

Table A-1. How the O'Reilly illustration department wants figure files named

Fig. No.


Caption (or description)



Overview of the Windows NT operating system environment.



Name space presented by the Object Manager.



Filter drivers in the driver hierarchy.



Local File System.



Hierarchical name space for directories and files.

As the example shows, the illustration department would like each illustration file named according to its place in the book. Each name starts with some letters identifying the book, followed by an underscore. Then there are two digits signifying the number of the chapter in which the figure appears. Then there are two more digits signifying the relative position of the figure within the chapter. Finally, there's the suffix indicating what kind of file it is. The illustration department would also like me to attach a list that looks like the table, associating figure numbers, filenames, and captions.

Naturally, as I've been writing the book, I haven't done any of that. It wouldn't have made sense, because I didn't know, as I wrote the book, exactly how many chapters there would be and what order they would be in, and exactly what illustrations there would be and what order they would be in. I've been cutting and pasting and rearranging right up until the last moment. My illustration files simply have whatever names I gave them at the time of creation; these names are generally pretty meaningless, and in the Finder they appear in alphabetical order, which is not at all the order in which they appear in the book. For example, here are the names of the illustration files for Chapter 2, as they appear in the Finder:


Now, however, the proverbial last moment has arrived. So it's time for me to grapple with the illustration department's requirements. The problem, therefore, is to rename these files in accordance with the chapter in which they appear and their order of appearance within it. Clearly I'm going to have to work in two places at once. In FrameMaker, I need to look at each illustration in order, and see what file on disk it corresponds to. In the Finder, I need to change the name of that file. Then, back in FrameMaker, I need to change the reference for each illustration, so that it points to the correct file under its new name.

This promises to be a massively painful, tedious, and error-prone tasknot something I'm looking forward to. Then I get an idea. Adobe FrameMaker is scriptable; in fact, it's extraordinarily scriptable. And so is the Finder. Perhaps this task can be automated using AppleScript.

AppleScript. The Definitive Guide
AppleScript: The Definitive Guide, 2nd Edition
ISBN: 0596102119
EAN: 2147483647
Year: 2006
Pages: 267
Authors: Matt Neuburg

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: