Chapter 2. Directory/File Snapshot Program

Have you ever installed a program and wanted to know exactly what was installed? Programs typically include numerous files and directories—in some cases hundreds. It can be difficult to determine what was put on the system. This can especially be important if, for instance, you are verifying an install to ensure that all the directories and files were placed on the system. Conversely, with an uninstall, you want to verify just the opposite—that everything that had been put on the system is now gone.

The File/DirectoryComparison program enables you to create a "snapshot" of your system based on a directory "base" you provide. It will also perform a comparison of two snapshots to show you the differences. This includes items missing from snapshot 1 but in snapshot 2, and items missing in snapshot 2 but present in snapshot 1.

Along the way, you'll learn several valuable things about Python and its features:

  • How to create and import modules

  • How to create and call functions

  • Getting user input and passing the value provided by the user to the program

  • How to find information related to the Python Standard Library

Using the Program

You can find the program located on the www.wrox.com page for this book. To run it, simply go to a command prompt, and from the directory on your system where the Chapter 2 program files are located, type the following: python snapshot.py.

This will bring up a menu like the one shown here:

DIRECTORY/FILE COMPARISON TOOL ==================================== ...

Get Python® Create-Modify-Reuse now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.