count_folder_files now returns a file count list for each subdirectory if subdirectories exist
This commit is contained in:
parent
bc94aad72d
commit
bd9f268f52
|
|
@ -40,8 +40,14 @@ def count_folder_files(folder_path):
|
||||||
return file_count
|
return file_count
|
||||||
# If subdirectories do exist, return the number of files in each subdirectory then this directory
|
# If subdirectories do exist, return the number of files in each subdirectory then this directory
|
||||||
else:
|
else:
|
||||||
|
file_count = ""
|
||||||
subdirectories = get_subdirectories(folder_path)
|
subdirectories = get_subdirectories(folder_path)
|
||||||
|
for directory in subdirectories:
|
||||||
|
file_count = file_count + str(sum(1 for entry in os.scandir(directory) if entry.is_file())) + " "
|
||||||
|
file_count = file_count + str(sum(1 for entry in os.scandir(folder_path) if entry.is_file()))
|
||||||
print(subdirectories)
|
print(subdirectories)
|
||||||
|
print(file_count)
|
||||||
|
return file_count
|
||||||
|
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user