Skip to content

Commit 9a6d14b

Browse files
committed
Update_[18_Aug_2025]_[File_Count]
1 parent 2d7c62c commit 9a6d14b

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

com/inbravo/.DS_Store

0 Bytes
Binary file not shown.

com/inbravo/file/file_count.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,40 @@
11
import os
2+
import sys
23

34
def count_sas_files(directory):
5+
"""
6+
Counts the number of '.sas' files in the given directory and its subdirectories.
7+
8+
Args:
9+
directory (str): The path to the directory to search.
10+
11+
Returns:
12+
int: The count of '.sas' files.
13+
"""
414
sas_file_count = 0
515
for root, _, files in os.walk(directory):
616
sas_file_count += sum(1 for file in files if file.endswith(".sas"))
717
return sas_file_count
818

919

1020
if __name__ == "__main__":
11-
folder_path = "//Users//inbravo//Library//CloudStorage//OneDrive-Impetus//pam//customer_artifacts//[2025]-[bfsi]-[ageas]-[leaplogic]-[sas-oracle-to-fabric-migration]//from_customer//code-recieved/Ageas"
21+
# Check if a folder path is provided as a command-line argument
22+
if len(sys.argv) < 2:
23+
print("Usage: python file_count.py <folder_path>")
24+
sys.exit(1)
25+
26+
folder_path = sys.argv[1]
27+
28+
# Validate the folder path
1229
if os.path.exists(folder_path) and os.path.isdir(folder_path):
13-
count = count_sas_files(folder_path)
14-
print(f"Number of '.sas' files: {count}")
30+
try:
31+
count = count_sas_files(folder_path)
32+
print(f"Number of '.sas' files: {count}")
33+
except PermissionError:
34+
print("Permission denied. Please check your folder permissions.")
35+
except Exception as e:
36+
print(f"An error occurred: {e}")
1537
else:
1638
print("Invalid folder path.")
1739
print("Please provide a valid directory path.")
18-
print("Example: /path/to/your/folder")
40+
print("Example: /path/to/your/folder")

0 commit comments

Comments
 (0)