Created
May 17, 2018 15:42
-
-
Save derekedelaney/5874387d59f0151a7bfa108bdd69aeb2 to your computer and use it in GitHub Desktop.
Prints out the directory of an empty file in a given root directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import argparse | |
def empty_files(rootdir): | |
for subdir, dirs, files in os.walk(rootdir): | |
for file in files: | |
if os.path.getsize(os.path.join(subdir, file)) == 0: | |
print os.path.join(subdir, file) | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument("root_dir", help="Name of the root directory") | |
args = parser.parse_args() | |
if not empty_files(args.root_dir): | |
sys.exit(1) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment