Skip to content

Commit 1164e10

Browse files
committed
added automovefiles script
1 parent 9b07800 commit 1164e10

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

AutoMoveFiles/AutoMoveFiles.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+

AutoMoveFiles/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+

0 commit comments

Comments
 (0)