From 6bec62a7617218cdfc130bfea055b5098bd2e2c2 Mon Sep 17 00:00:00 2001 From: Azalea <22280294+hykilpikonna@users.noreply.github.com> Date: Sat, 24 Aug 2024 00:47:58 -0400 Subject: [PATCH] [+] ls-items --- scripts/bin/ls-items | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 scripts/bin/ls-items diff --git a/scripts/bin/ls-items b/scripts/bin/ls-items new file mode 100644 index 0000000..28868ea --- /dev/null +++ b/scripts/bin/ls-items @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +# ls-items : Lists the number of files in each sub-directory of the target dir +import argparse +from pathlib import Path + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Lists the number of files in each sub-directory of the target dir") + parser.add_argument("dir", help="The target directory", default=".", nargs="?") + args = parser.parse_args() + + target = Path(args.dir) + if not target.is_dir(): + print(f"{target} is not a directory") + + for subdir in target.iterdir(): + if subdir.is_dir(): + print(f"{subdir.name}: {len(list(subdir.iterdir()))}") + \ No newline at end of file