I would think you would get an `OSError` here more easily. But then again you might have good reason for catching `IOError` only.

Also, it is better to narrow down the `try/except` blocks to where you think that exception may be raised. I would think that could be raised first when calling `os.listdir` so why not do the `try/except` just there?