A Python command-line tool for managing files and directories.
This project provides two main features:
- Organizing files based on their extensions
- Automatically creating files and directories from a JSON configuration
The application is designed to be used through the command line with Python argument parsing.
The file organizer scans a directory and organizes files based on their extensions.
For example, if a directory contains:
my_folder/
├── document.txt
├── notes.txt
├── image.png
├── photo.jpg
├── script.py
└── data.json
After running the organizer, the files are grouped into directories based on their extensions
```text
my_folder/
├── txt/
│ ├── document.txt
│ └── notes.txt
│
├── png/
│ └── image.png
│
├── jpg/
│ └── photo.jpg
│
├── py/
│ └── script.py
│
└── json/
└── data.json
The organizer also supports dividing files into smaller groups.
For example, using:
--cluster 5files can be divided into groups of five inside numbered directories.
Example:
txt/
├── 1/
│ ├── file01.txt
│ ├── file02.txt
│ ├── file03.txt
│ ├── file04.txt
│ └── file05.txt
│
└── 2/
├── file06.txt
├── file07.txt
└── file08.txt
The second feature allows you to define a directory structure inside a JSON configuration file.
The program reads the configuration and automatically creates the required directories and files.
This can also be used for nested directory structures.
Example:
project/
├── src/
│ ├── main.py
│ └── utils.py
│
├── tests/
│ └── test_main.py
│
└── README.md
The structure can be represented using a JSON configuration file, and the program will create it automatically.
This makes it possible to create complex directory structures without manually creating every file and folder.
- Python
- Object-Oriented Programming
- argparse
- JSON
- File System Operations
The application provides two main commands:
sort create
The sort command organizes files in a directory based on their extensions.
Basic Usage
python file_manager.py sort --path ./my_folder/This scans the specified directory and moves files into directories based on their extensions.
You can also divide files into groups using the --cluster option.
For example:
python file_manager.py sort --path ./my_folder/ --cluster 5This organizes the files and divides them into groups of five.
The create command creates a directory and file structure based on a JSON configuration file.
python file_manager.py create --config-file config.jsonThe --config-file option specifies the path to the JSON configuration containing the desired structure.
git clone https://github.com/alimhmdabesi/file-management-cli.git
cd file-management-cli
# Run
python file_manager.py