A Python script to synchronize two folders one-way.
Table of Contents
This file synchronizer periodically maintains an identical copy of a source folder in a destination folder (replica). Any file or folder changes with operations like creation, deletion, modification (eg: rename, content change) are handled by this script.
- Python (version >= 3.8)
To get a local copy up and running, follow the steps mentioned below. (These steps are for MacOS)
- VSCode / Terminal
- Git Repo
- Clone the repo to your local destination on computer
git clone https://github.com/samyuktaprabhu/file-synchronizer.git
- Create a new Output file (eg. 'output.txt')
- In the same root folder, create 2 folders - source and replica. Note down its path.
- Open Terminal
- Navigate to the root folder of the cloned project
- In the terminal, run the command in this format-
python3 synctask.py <your_source_file_path> <your_replica_file_path> <your_sync_interval> <your_log_file_path>
Example:
python3 synctask.py /Users/username/Desktop/file-synchronizer-master/source/ /Users/username/Desktop/file-synchronizer-master/replica/ 5 /Users/username/Desktop/file-synchronizer-master/output.txt
- Perform any of the operations mentioned in the description aboce to see the synchronization between the files / folders.
Python has been used to write this script.
For information, please refer to the Documentation
Following libraries have been used in the script.
For information on 'os', please refer to the Documentation
For information on 'shutil', please refer to the Documentation
For information on 'threading', please refer to the Documentation
For information on 'sys', please refer to the Documentation
For information on 'datetime', please refer to the Documentation
Email - samyuktaprabhu@gmail.com