Python automation script that moves files from one directory to another
This Python script organizes files in a specified source directory based on their types and moves them to designated folders in a destination directory.
-
Clone the Repository
git clone https://github.com/your-username/your-repository.git cd your-repository -
Run the Script
python organize_files.py
-
Specify Source and Destination Directories Open
organize_files.pyand modify thesource_diranddestination_dirvariables to point to your desired source and destination directories.source_dir = '/path/to/source_directory' destination_dir = '/path/to/destination_directory'
-
Execute the Script:** Run the script again after modifying the directories.
python organize_files.py
##Customization
-
The script categorizes files into the following types:
- Images:
.jpg,.jpeg,.png,.gif,.heic - Documents:
.pdf,.doc,.docx,.txt,.zip,.pkg,.md - Videos:
.mp4,.avi,.mkv,.mov
- Images:
-
You can customize the file types and their corresponding destination folders by modifying the
file_typesdictionary in the script.
file_types = {
'Images': ['.jpg', '.jpeg', '.png', '.gif', '.heic'],
'Documents': ['.pdf', '.doc', '.docx', '.txt', '.zip', '.pkg', '.md'],
'Videos': ['.mp4', '.avi', '.mkv', '.mov']
}- Python 3.x
-
The script will create destination folders if they do not exist.
-
Make sure to modify the
source_diranddestination_dirvariables to match your desired directories.