#license: I grant free for all legal and human-rights purposes
import os # to work with files
import glob # to search for files
import sys # to support command line/terminal inputs
# THIS IS ONLY INTEDED TO DO A SIMPLE TOTAL NUMBER AND TOTAL BYTE COUNT
# OF JUST FILES (NOT DIRECTORIES)
# NOT INTENDED FOR EXACT COMPARING FILE BY FILE!
# if there were terminal/command line arguments, assume they are dir paths
if len(sys.argv) > 1:
COMPARE_DIRS = sys.argv[1:] # first argument is this file name, useless for this program
# else, use in-code-defined paths:
else:
print(f"No directories set, using directories defined in this python code. ({sys.argv[0]})")
COMPARE_DIRS = [
"/EXAMPLE/PATH/TO/ONE/DIR",
"/EXAMPLE/PATH/TO/ANOTHER/DIR",
# ...
]
print("### WELCOME TO QUICK COMPARE DIRS ###")
print("Going to compare:")
for i, folder in enumerate(COMPARE_DIRS):
print(f"DIRECTORY {i}: {folder}")
print("... comparing ... please wait ...")
# get list of all FILES (not directories) in that folder recursively
file_lists = {}
for folder in COMPARE_DIRS:
file_lists[folder] = [f for f in glob.iglob(f"{folder}/**", recursive=True) if os.path.isfile(f)]
# count all FILE byte sizes for each list as a manual size addition (NOT SYSTEM TOTAL COUNT!)
file_size_totals = {}
for folder in COMPARE_DIRS:
file_size_totals[folder] = 0
for file in file_lists[folder]:
file_size_totals[folder] += os.path.getsize(file)
print("_" * 80) # specific PYTHON feature
print("TOTAL FILE COUNTS: ")
for folder, file_list in file_lists.items():
print(f"{len(file_list)} [{folder}]")
print("_" * 80) # specific PYTHON feature
print("TOTAL FILE COUNTS: ")
for folder, file_size_total in file_size_totals.items():
print(f"{file_size_total} [{folder}]")