Folder Class¶
- class data_classes.folder.Folder(folder_dir)
Bases:
objectBase class for managing folders.
This class provides methods to interact with and manage files within a specified folder directory.
- folder_dir
The directory path of the folder.
- Type:
str
- __init__(folder_dir)
Initialize the Folder object with the specified folder directory.
- __str__()
Return a string representation of the Folder object.
- get_num_files(file_extension, recursive)
Get the number of files in the folder with a specific file extension.
- get_directories_by_extension(file_extension, recursive, subfolder='')
Get a list of file directories with a specific file extension in the folder.
- get_directories_by_extension(file_extension, recursive, subfolder='')
Get a list of file directories with a specific file extension in the folder.
- Parameters:
file_extension (str) – The file extension (e.g., ‘.txt’, ‘.csv’).
recursive (bool) – Boolean flag to indicate whether to search subdirectories recursively.
subfolder (str, optional) – Optional subfolder name to search within.
- Returns:
List of file directories matching the criteria.
- Return type:
list of str
- get_num_files(file_extension, recursive)
Get the number of files in the folder with a specific file extension.
- Parameters:
file_extension (str) – The file extension (e.g., ‘.txt’, ‘.csv’).
recursive (bool) – Boolean flag to indicate whether to search subdirectories recursively.
- Returns:
The number of files with the specified extension.
- Return type:
int