Identify yourself: (Mention in which program you are contributing. Eg. For a WoB 2024 participant, it's WoB Participant) Gssoc extd. Contributor
Closes: #9
Snippet Details 📃
Snippet Name: file_organizer.py
Category: File_Organizer
Function Name: organize_files_by_type
Summary of Changes
The organize_files_by_type snippet sorts files in a specified directory into categorized subfolders like 'Images', 'Documents', and 'Videos', enhancing file organization and accessibility.
Users must ensure the folder path exists, as the function raises a ValueError for invalid paths. Unrecognized file types will be noted, helping users identify files that weren't categorized.
Example Usage
# Example usage of the organize_files_by_type function
folder_to_organize = r"path_to_the_folder" # Replace with the actual folder path
try:
organize_files_by_type(folder_to_organize)
print("Files organized successfully.")
except ValueError as e:
print(e)
Type of Change ☑️
What sort of change have you made:
[ ] Bug fix (non-breaking change which fixes an issue)
[x] New feature (non-breaking change which adds functionality)
[ ] Code style update (formatting, local variables)
[ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
[ ] This change requires a documentation update
How Has This Been Tested? ⚙️
The organize_files_by_type function was tested using the unittest framework with a temporary directory containing various file types to ensure accurate categorization into appropriate folders. It also confirmed that unrecognized files remained in the root directory and validated error handling for invalid paths.
Changes were verified by executing all tests successfully, conducting a code review and performing manual tests to confirm proper file organization.
Checklist ☑️
[x] My code follows the guidelines of this project.
[x] I have performed a self-review of my own code.
[x] I have commented my code, particularly where it was hard to understand.
[x] I have made corresponding changes to the documentation.
[x] My changes generate no new warnings.
[x] I have added tests that prove my fix is effective or that my feature works.
[x] Any dependent changes have been merged and published in downstream modules.
Issue Title : [Documentation Update]: Addition of File organizer snippet
WoB Participant
) Gssoc extd. ContributorCloses: #9
Snippet Details 📃
file_organizer.py
File_Organizer
organize_files_by_type
Summary of Changes
organize_files_by_type
snippet sorts files in a specified directory into categorized subfolders like 'Images', 'Documents', and 'Videos', enhancing file organization and accessibility.ValueError
for invalid paths. Unrecognized file types will be noted, helping users identify files that weren't categorized.Example Usage
Type of Change ☑️
What sort of change have you made:
How Has This Been Tested? ⚙️
organize_files_by_type
function was tested using theunittest
framework with a temporary directory containing various file types to ensure accurate categorization into appropriate folders. It also confirmed that unrecognized files remained in the root directory and validated error handling for invalid paths.Checklist ☑️