Using TextWrangler To Browse And Modify Aperture Libraries

TextWrangler is a freeware text editor and general-purpose text-processing tool published by Bare Bones Software. One of the things it is good at is processing a whole folder hierarchy of files at once, making the same edits to each with just a few mouse clicks. Since Aperture libraries and vaults are just large file hierarchies, I can use this tool to browse and modify them.

TextWrangler can be set to automatically process hundreds or thousands of files, so it is a really fast way to destroy an Aperture library too. Conversely, if I really know what I am doing, it is a fast way to find things and make changes that Aperture cannot, such as recovering from corruption, removing problem data, or globally changing parameters.

The simplest way to use TextWrangler is to open a new blank document and drag an Aperture library onto it. TextWrangler reads the file hierarchy and displays it as tab-indented text:

tr12

Now I can browse and search this text document. If there are lines that I don't want to see I can use the Text > Process Lines Containing... function to delete or modify all lines that matches criteria I define, such as file name endings or character patterns.

I can also do the same thing with two libraries and two windows and then go to the menu and compare their contents with Search > Compare Two Front Documents. In this way I can compare the contents of two Aperture libraries side by side:

tr13

Another way to use TextWrangler is to look inside the files in the library. In the example that follows I browse all my library image file information files (only the XML .apfile files) and examine the information they store about the disk that hosts the image.

I launch TextWrangler and hit command F to bring up the find panel. To get TextWrangler to open the library, I locate it on my hard drive and drag it onto the drawer on the left (the Open dialog will not allow it to be selected):

tr5

Pressing the Options... button bottom right allows me to set up a filter so that TextWrangler will only open certain files in the library. I set up the dialog as below:

tr2

I click on Edit Filter to set up a new filter called apfiles that will make TextWrangler only open the XML files that describe images in the Aperture library:

tr3

Closing that and clicking OK takes me back to the Find window. By typing diskUuid into the top search box and clicking Find All I get a window that shows all the matches:

tr6
I can scroll up and down by clicking on the top pane and using the up and down arrow keys. This allows me to view each file in turn in the lower panel and look at the disk and other data that the apfile contains. It's so fast that I can easily flick back and forth across several files and see the differences.

This technique can be used to make global edits on the Aperture library. By filling the Replace With box and clicking Replace All, TextWrangler will go through all the matching files and match and replace the values. Of course this is very dangerous, so I recommend only working on a copy of the library, and even then going very carefully. Since exported projects are almost identical to a library, they make a good practice area.

Many changes to the files that make up the library also have to be made to the database if they are to have any effect. But since the database is out of bounds to applications like TextWrangler, the only way to accomplish this is to quit Aperture, delete the database and then open the library, so causing Aperture to rebuild it. Another way to achieve the same effect is to launch Aperture with option and command held down.

I've only scratched the surface of what TextWrangler can do. It's a very powerful tool and can be put to good use to explore and solve Aperture library problems. But be careful with it!

The Bagelturf site welcomes Donations of any size