File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 11from watchdog .observers import Observer
2+ import time
23from watchdog .events import FileSystemEventHandler
34import os
5+ import json
46
57class Handler (FileSystemEventHandler ):
68 def on_modified (self , event ):
@@ -9,13 +11,17 @@ def on_modified(self, event):
911 dst = f"{ destination_folder } /{ file } "
1012 os .rename (src = src , dst = dst )
1113
12-
13-
1414if __name__ == "__main__" :
1515 watched_folder = input ("Paste the path to the folder to be tracked: " )
1616 destination_folder = input ("Paste the path to the destination folder: " )
1717 handler = Handler ()
1818 observer = Observer ()
1919 observer .schedule (event_handler = handler , path = watched_folder , recursive = True )
2020 observer .start ()
21+ try :
22+ while True :
23+ time .sleep (10 )
24+ except KeyboardInterrupt :
25+ observer .stop ()
26+ observer .join ()
2127
You can’t perform that action at this time.
0 commit comments