Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
30 lines (25 loc) · 907 Bytes

File metadata and controls

30 lines (25 loc) · 907 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
# pip install watchdog /or/ poetry add watchdog (required)
import time
import os
import json
class Handler(FileSystemEventHandler):
def on_modified(self, event):
for file in os.listdir(watched_folder):
src = f"{watched_folder}/{file}"
dst = f"{destination_folder}/{file}"
os.rename(src=src, dst=dst)
if __name__=="__main__":
watched_folder = input("Paste the path to the folder to be tracked: ")
destination_folder = input("Paste the path to the destination folder: ")
handler = Handler()
observer = Observer()
observer.schedule(event_handler=handler, path=watched_folder, recursive=True)
observer.start()
try:
while True:
time.sleep(10)
except KeyboardInterrupt:
observer.stop()
observer.join()
Morty Proxy This is a proxified and sanitized view of the page, visit original site.