O'Reilly logo

AppleScript: The Missing Manual by Adam Goldstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting File Information

Back in Chapter 5, you learned how to use the Finder to gather information about a file—like its modification date, for example . As it turns out, however, there's a much more powerful command for gathering file information: info for. This command has a number of advantages over scripting the Finder:

  • Info for provides a more complete analysis of files. In addition to telling you a file's name, modification date, and size (all things you can get by commanding the Finder), the info for command lets you get a file's displayed name (how the file name actually looks in the Finder) and name extension (the short string that comes after the period in a file's name), among other useful properties.

Note

Lest you think the info for command can access everything about a file, there are actually a few pieces of information you can get only by commanding the Finder. These include a file's comment (its Finder note, as described on Note) and a file's owner (the person who created it). Therefore, until Apple updates the info for command to access the same information as the Finder, you'll have to live with using a combination of both methods to access complete file information.

  • The info for command doesn't require a tell statement directed at the Finder. You'll save two lines of code automatically: tell and end tell.

  • The info for command returns its information as a record. Among other things, this means you can use the info for command on a list of files and end up with a database ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required