A Python script that organizes files in a directory based on their file types. The file types and their corresponding folder names are defined in a JSON file (file_types.json), allowing easy customization.
- Organizes files by type: Moves files into separate folders based on their extensions.
- Customizable folder structure: Define destination folders for specific file types in
file_types.json. - Command-line interface: Configure source and destination directories through CLI arguments.
- Python 3.6 or higher
- Clone or download the repository.
- Ensure
file_types.jsonexists in the same directory as the script and defines file types like this:{ ".jpg": "images", ".png": "images", ".pdf": "pdfs", ".mp3": "music", ".zip": "zip", ".xlsx": "excel" }
Run the script from the command line:
python organizer.py --rootsrc /path/to/source --rootdst /path/to/destination-rsor--rootsrc(required): Directory containing files to organize.-rdor--rootdst(optional): Directory to place organized folders. Defaults to the source directory if not provided.
python organizer.py --rootsrc ./Downloads --rootdst ./OrganizedDownloadsThis example organizes files from Downloads into the OrganizedDownloads folder. Each file type (e.g., .jpg, .pdf) will be moved to its designated folder as specified in file_types.json.
- Ensure
file_types.jsonincludes all desired file types; files with extensions not listed are ignored. _cacheoptimizes folder creation by caching destination folders for each file type, reducing redundant checks.
Free to every one