Coders Packet

Program for File Sorter and Organiser in a Particular Folder Using Python

By SAGAR GHUGUSKAR

This Python program automatically sorts files in a specified folder into different categories based on their file extensions.

The program is designed to organize files within a specified folder by sorting them into different categories based on their file extensions. It helps in better organizing and managing files, making it easier to locate specific types of files.

The program starts by defining a dictionary called categories, which maps each category name to a list of file extensions associated with that category. The categories include images, documents, videos, audio, executables, and compressed files. Each category represents a specific file type commonly found in computer systems.

Next, the program iterates through each file in the specified folder using the os.listdir() function. For each file, it checks if it is a file (not a directory) using os.path.isfile().

If the item is indeed a file, the program extracts its file extension using os.path.splitext() and converts it to lowercase. It then compares the file extension against the list of extensions in the categories dictionary.

If a matching extension is found within a category, the program creates a new folder with the category name within the same folder as the source file, using os.makedirs(). It ensures that the folder is created only if it doesn't already exist. Then, it moves the file to the newly created category folder using shutil.move().

Once a matching category is identified and the file is moved, the program breaks out of the inner loop, as there is no need to check other categories for that particular file.

By running this program on a specified folder, files with compatible extensions will be automatically sorted into their respective categories. This results in a more organized folder structure, where files of similar types are grouped together for easier access and management.

The program provides flexibility in terms of adding, modifying, or removing categories and their associated file extensions. The categories dictionary can be customized according to specific needs and preferences.

Using this file sorting program can save time and effort in manually organizing files, ensuring a more streamlined and efficient file management system.

 

TECHNOLOGY/LANGUAGE:- PYTHON

LIBRARY:- SHUTIL AND OS

PLATFORM:-VISUAL STUDIO CODE

 

BEFORE EXECUTION OF PROGRAM

 

 

PROGRAM

 

RESULT

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by SAGAR GHUGUSKAR (SAGAR)

Download packets of source code on Coders Packet