11import os
2+ import sys
23
34def 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
1020if __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