Skip to content

Commit f2a220a

Browse files
authored
Merge branch 'main' into edit-readme
2 parents 4cc62c0 + f356b51 commit f2a220a

22 files changed

+125
-118
lines changed

AutoMoveFiles/AutoMoveFiles.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from watchdog.observers import Observer
2+
from watchdog.events import FileSystemEventHandler
3+
4+
# pip install watchdog /or/ poetry add watchdog (required)
5+
6+
import time
7+
import os
8+
import json
9+
10+
class Handler(FileSystemEventHandler):
11+
def on_modified(self, event):
12+
for file in os.listdir(watched_folder):
13+
src = f"{watched_folder}/{file}"
14+
dst = f"{destination_folder}/{file}"
15+
os.rename(src=src, dst=dst)
16+
17+
if __name__=="__main__":
18+
watched_folder = input("Paste the path to the folder to be tracked: ")
19+
destination_folder = input("Paste the path to the destination folder: ")
20+
handler = Handler()
21+
observer = Observer()
22+
observer.schedule(event_handler=handler, path=watched_folder, recursive=True)
23+
observer.start()
24+
try:
25+
while True:
26+
time.sleep(10)
27+
except KeyboardInterrupt:
28+
observer.stop()
29+
observer.join()
30+

AutoMoveFiles/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# AutoMoveFiles
2+
The script moves files automatically from a tracked folder to the destination folder.
3+
4+
## Getting started
5+
- `pip install watchdog` or `poetry add watchdog`
6+
- `cd AutoMoveFiles`
7+
- `python -m AutoMoveFiles.py`
8+
- Enter the path to the source folder
9+
> for example: `C:\Users\example\Downloads`
10+
- Enter the path to destination folder
11+
> for example: `C:\Users\example\Documents`
12+
1.11 KB
Binary file not shown.

AutoMoveFiles/poetry.lock

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AutoMoveFiles/pyproject.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[tool.poetry]
2+
name = "automovefiles"
3+
version = "0.1.0"
4+
description = ""
5+
authors = ["HishamKhalil1990 <hisham.khalil1990@gmail.com>"]
6+
7+
[tool.poetry.dependencies]
8+
python = "^3.8"
9+
watchdog = "^2.1.3"
10+
11+
[tool.poetry.dev-dependencies]
12+
13+
[build-system]
14+
requires = ["poetry-core>=1.0.0"]
15+
build-backend = "poetry.core.masonry.api"

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Contributing to Python-Project-Scripts
2-
Thanks for your interest in Python. Our goal is to bring fast, open-source python projects to all communities.
3-
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
4-
Please note we have a code of conduct, please follow it in all your interactions with the project.
2+
Thanks for your interest in Python. Our goal is to bring fast, reliable, and trouble-free open-source python projects to all communities.
3+
We love your input! We want to make every contribution to this project as transparent and effortless as possible.
4+
Please note that we have a code of conduct that we need to follow moving forward in all your interactions with the project.
55

66
- Reporting a bug
77
- Discussing the current state of the code

Compress Image/1_compressed.jpg

-1.67 MB
Binary file not shown.

Compress Image/code.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

Compress Image/img_comp.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from PIL import Image
2+
3+
def compress_image(default_image=Image.open('original_image.jpg')):
4+
''' Takes an image file and compress it with losing image quality. '''
5+
6+
''' If no image file is provided, the default image will be compressed '''
7+
8+
# Get image 'width' and 'height'
9+
w, h = default_image.size
10+
# compress image
11+
default_image = default_image.resize((h, w), Image.ANTIALIAS)
12+
# return compressed image
13+
return default_image.save('compressed_image.jpg')
14+
15+
# Run
16+
compress_image()
File renamed without changes.

0 commit comments

Comments
 (0)