File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ from watchdog .observers import Observer
2+ from watchdog .events import FileSystemEventHandler
3+ import os
4+
5+ class Handler (FileSystemEventHandler ):
6+ def on_modified (self , event ):
7+ for file in os .listdir (watched_folder ):
8+ src = f"{ watched_folder } /{ file } "
9+ dst = f"{ destination_folder } /{ file } "
10+ os .rename (src = src , dst = dst )
11+
12+
13+
14+ if __name__ == "__main__" :
15+ watched_folder = input ("Paste the path to the folder to be tracked: " )
16+ destination_folder = input ("Paste the path to the destination folder: " )
17+ handler = Handler ()
18+ observer = Observer ()
19+ observer .schedule (event_handler = handler , path = watched_folder , recursive = True )
20+ observer .start ()
21+
Original file line number Diff line number Diff line change 1+ # AutoMoveFiles
2+ The script moves files automatically from a tracked folder to the destination folder.
3+
4+ ## Getting started
5+ - ` pip install watchdog `
6+ - ` python AutoMoveFiles.py `
7+ - Enter the path to the source folder
8+ > for example: ` C:\Users\example\Downloads `
9+ - Enter the path to destination folder
10+ > for example: ` C:\Users\example\Documents `
11+
You can’t perform that action at this time.
0 commit comments