-
Notifications
You must be signed in to change notification settings - Fork 689
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/pip/projects/QRCode-Generator/pil…
…low-10.2.0
- Loading branch information
Showing
8 changed files
with
428 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
speedtest==0.0.1 | ||
speedtest_cli==2.1.3 | ||
speedtest_cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import os | ||
import shutil | ||
|
||
def main(): | ||
dir_path = input("Enter the directory path of the files: ") | ||
|
||
try: | ||
print("Organising your files into [ images - music - video - executable - archive - torrent - document - code - design files]") | ||
for filename in os.listdir(dir_path): | ||
absname = os.path.join(dir_path, filename) | ||
# Check if files are images and you can add more extensions | ||
if filename.lower().endswith((".png", ".jpg", ".jpeg", ".gif", ".bmp", ".pbm", ".pnm")): | ||
# If images folder doesn't exist then create new folder | ||
if not os.path.exists("images"): | ||
os.makedirs("images") | ||
shutil.move(absname, "images") | ||
|
||
# Check if files are music and you can add more extensions | ||
elif filename.lower().endswith((".wav", ".mp3", ".flac", ".3gp", ".aa", ".aax", ".aiff", ".raw")): | ||
# If music folder doesn't exist then create new folder | ||
if not os.path.exists("music"): | ||
os.makedirs("music") | ||
shutil.move(absname, "music") | ||
|
||
# Check if files are videos and you can add more extensions | ||
elif filename.lower().endswith((".webm", ".mp4")): | ||
# If video folder doesn't exist then create new folder | ||
if not os.path.exists("video"): | ||
os.makedirs("video") | ||
shutil.move(absname, "video") | ||
|
||
# Check if files are executables | ||
elif filename.lower().endswith((".exe", ".msi", ".deb" , "dmg")): | ||
# If executables folder doesn't exist then create new folder | ||
if not os.path.exists("executables"): | ||
os.makedirs("executables") | ||
shutil.move(absname, "executables") | ||
|
||
# Check if files are archive files | ||
elif filename.lower().endswith((".rar", ".tar" , ".zip" , ".gz")): | ||
# If archive folder doesn't exist then create new folder | ||
if not os.path.exists("archives"): | ||
os.makedirs("archives") | ||
shutil.move(absname, "archives") | ||
|
||
# Check if files are torrent files | ||
elif filename.lower().endswith((".torrent",)): | ||
# If torrent folder doesn't exist then create new folder | ||
if not os.path.exists("torrent"): | ||
os.makedirs("torrent") | ||
shutil.move(absname, "torrent") | ||
|
||
# Check if files are documents | ||
elif filename.lower().endswith((".txt", ".pdf", ".docx" , "doc")): | ||
# If documents folder doesn't exist then create new folder | ||
if not os.path.exists("documents"): | ||
os.makedirs("documents") | ||
shutil.move(absname, "documents") | ||
|
||
# Check if files are code files | ||
elif filename.lower().endswith((".py", ".php", ".html" , ".css" , ".js")): | ||
# If code folder doesn't exist then create new folder | ||
if not os.path.exists("code"): | ||
os.makedirs("code") | ||
shutil.move(absname, "code") | ||
|
||
# Check if files are design files | ||
elif filename.lower().endswith((".psd", ".ai")): | ||
# If design folder doesn't exist then create new folder | ||
if not os.path.exists("design-files"): | ||
os.makedirs("design-files") | ||
shutil.move(absname, "design-files") | ||
|
||
except OSError: | ||
print("Error happened ...... try again") | ||
finally: | ||
# When script is finished clear screen and display message | ||
os.system("cls" if os.name == "nt" else "clear") | ||
print("Finished organising your files") | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import os | ||
|
||
def main(): | ||
img_types = ['jpg', 'png', 'jpeg'] | ||
dir_path = input("Enter the directory path of the images: ") | ||
|
||
for i, f in enumerate(os.listdir(dir_path)): | ||
absname = os.path.join(dir_path, f) | ||
img_type = absname.split('.')[-1] | ||
|
||
if img_type in img_types: | ||
while True: | ||
newname = input(f"Enter the new name for {f} (without extension): ") | ||
newname = '{}.{}'.format(newname, img_type) | ||
new_absname = os.path.join(dir_path, newname) | ||
if not os.path.exists(new_absname): | ||
os.rename(absname, new_absname) | ||
break | ||
else: | ||
print("A file with this name already exists. Please enter a different name.") | ||
|
||
print('Done renaming images.') | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Pillow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
from PIL import Image | ||
|
||
def resize_image(image_path, size): | ||
im = Image.open(image_path) | ||
im = im.resize(size) | ||
return im | ||
|
||
|
||
def main(): | ||
choice = input("Do you want to resize multiple images? (yes/no): ") | ||
width = int(input("Enter the width: ")) | ||
height = int(input("Enter the height: ")) | ||
size = (width, height) | ||
|
||
images = [] | ||
if choice.lower() == 'yes': | ||
dir_path = input("Enter the directory path of the images: ") | ||
for filename in os.listdir(dir_path): | ||
if filename.endswith('.png') or filename.endswith('.jpg'): | ||
image_path = os.path.join(dir_path, filename) | ||
images.append((image_path, resize_image(image_path, size))) | ||
else: | ||
image_path = input("Enter the image path: ") | ||
images.append((image_path, resize_image(image_path, size))) | ||
|
||
output_folder = input("Enter the output folder: ") | ||
os.makedirs(output_folder, exist_ok=True) | ||
|
||
for image_path, im in images: | ||
new_image_name = input(f"Enter the new name for {os.path.basename(image_path)}: ") | ||
output_path = os.path.join(output_folder, new_image_name) | ||
im.save(output_path) | ||
print(f"Resized image is saved as {output_path}.") | ||
|
||
print('Done resizing images.') | ||
|
||
if __name__ == "__main__": | ||
main() |