From df65a72fa3de039eaf3b5f054fee880894d6defa Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 26 May 2024 22:42:20 -0400 Subject: [PATCH] Removed pauses and debug text --- CountFolderFiles.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/CountFolderFiles.py b/CountFolderFiles.py index 24f9678..65f6539 100644 --- a/CountFolderFiles.py +++ b/CountFolderFiles.py @@ -13,7 +13,6 @@ def append_to_folder_name(folder_path, suffix): # Rename the folder os.rename(folder_path, os.path.join(os.path.dirname(folder_path), new_folder_name)) print(f"Folder renamed to: {new_folder_name}") - os.system("pause") except FileNotFoundError: print(f"Error: Folder '{folder_path}' not found.") os.system("pause") @@ -31,9 +30,7 @@ def count_subdirectories(path): def count_folder_files(folder_path): try: # If no subfolders exist, return the number of files in the folder - print("entering count_subdirectories") num_subdirectories = count_subdirectories(folder_path) - print("exiting count_subdirectories") if num_subdirectories == 0: # Count the number of files in the folder @@ -43,20 +40,17 @@ def count_folder_files(folder_path): # If subdirectories do exist, return the number of files in each subdirectory then this directory else: file_count = "" - print("entering get_subdirectories") subdirectories = get_subdirectories(folder_path) for i, directory in enumerate(subdirectories): file_count = file_count + str(sum(1 for entry in os.scandir(directory) if entry.is_file())) #If there's another element, add a space (Keep code this way so that append folder files looks right) if i != len(subdirectories) - 1: file_count = file_count + " " - print(file_count) #Append the number of files in the folder unless if there are none if (sum(1 for entry in os.scandir(folder_path) if entry.is_file()) > 0): file_count = file_count + " " + str(sum(1 for entry in os.scandir(folder_path) if entry.is_file())) print(subdirectories) print(file_count) - os.system("pause") return file_count @@ -85,26 +79,19 @@ def clean_directory_name(directory_name): return directory_name.rsplit(" [", 1)[0] def main(): - print("program started") - print(sys.argv) if len(sys.argv) < 2: print("Usage: CountFolderFiles ") sys.exit(1) args = sys.argv[1:] - print(args) - os.system("pause") for arg in args: directory_name = arg - print("entering count_folder_files") suffix = count_folder_files(directory_name) # If [num] already exists at the end of the string, remove it so we can update it directory_name_cleaned = clean_directory_name(directory_name) if check_directory_exists(directory_name): print(f"Directory '{directory_name}' exists.") - os.system("pause") - #If folder was counted already, remove the old count. Ex: dirname_[1] -> dirname os.rename(directory_name, os.path.join(os.path.dirname(directory_name), directory_name_cleaned)) directory_name = directory_name_cleaned @@ -112,7 +99,6 @@ def main(): append_to_folder_name(directory_name, suffix) else: print(f"Directory '{directory_name}' does not exist.") - os.system("pause") if __name__ == "__main__": main()