Skip to content

Commit 9a6943e

Browse files
finished the feature
1 parent 1164e10 commit 9a6943e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

AutoMoveFiles/AutoMoveFiles.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from watchdog.observers import Observer
2+
import time
23
from watchdog.events import FileSystemEventHandler
34
import os
5+
import json
46

57
class 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-
1414
if __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

0 commit comments

Comments
 (0)