Tip: Generate preview images for a collection of documents

You can use a terminal command to save generated previews of documents.

Apple's QuickLook technology in OS X is a quick way to preview a document's contents before opening the document's handling program. QuickLook works by using a small plug-in that reads the document's format and generates a small PDF, HTML, or thumbnail preview of the document that is presented to you as a representation of its layout.

The ability for OS X to generate a preview of a document is convenient for QuickLook, but also may be handy for other uses as well. For example, MacFixIt reader Paul recently wrote in wondering how one might use this to create images for a Web gallery:

I am looking for a Mac utility to batch generate "X-ray" thumbnails of common files -- exactly the kind that Mac OS X QuickLook makes, but its previews can't be saved readily to actual image files. I have not been able to find any program/app/utility/automator action that does this. I need to batch generate previews (saved as small PNGs) of 300+ files like DOCX, PPT, XLS, PDF, ZIP, so I can create a Web gallery with hyperlinks to those files.

Unfortunately the QuickLook service itself does not support options to save its generated previews, but you can make use of the management tool for the QuickLook server, which allows developers to test their QuickLook plug-ins by saving the results in a separate folder. This tool can be used with a terminal script that can access documents in a folder and then run this command on each of them sequentially, followed by dumping the generated image to a folder of choice.

To do this, run the following steps:

  1. Open Terminal and type "find" followed by a single space.
  2. Drag a folder containing the files of interest (e.g., a collection of your various documents to create into images) to the Terminal window to complete the full file path to it.
  3. Complete the command by typing the following:

    -type f -exec qlmanage -o ~/Desktop -t -s 2048 {} \;

When finished, the command should look like the following:

find /Users/username/folder/ -type f -exec qlmanage -o ~/Desktop -t -s 2048 {} \;

Note that the "~/Desktop" component is the destination where the files will be saved, and you can change this to a folder path of your choice. As with the first folder path after typing "find," you can do this by dragging the destination folder of interest to the Terminal window after you have entered the "-o" flag.

With the command assembled, execute it by pressing Enter; the system should create 2,048x2,048 PNG images of all the files and save them to your desktop. You can change this size to any other size by adjusting the number in the command accordingly.



Questions? Comments? Have a fix? Post them below or e-mail us!
Be sure to check us out on Twitter and the CNET Mac forums.

Tags:
Computers
Path
About the author

    Topher, an avid Mac user for the past 15 years, has been a contributing author to MacFixIt since the spring of 2008. One of his passions is troubleshooting Mac problems and making the best use of Macs and Apple hardware at home and in the workplace.

     

    Join the discussion

    Conversation powered by Livefyre

    Don't Miss
    Hot Products
    Trending on CNET

    HOT ON CNET

    Still taking notes with pen and paper?

    Bump up your grades and school supplies with these laptops, desktops, and tablets!