Instead of os.path.exists you may want to specifically use os.path.isdir and isfile. isdir checks if the path matches an existing folder, and isfile checks for files. It is possible for the path you pass to be valid but not of the correct type for your purposes, which would be a significant error...