Skip to content

Commit

Permalink
add group_files.py
Browse files Browse the repository at this point in the history
  • Loading branch information
BradleyYeo committed Apr 9, 2024
1 parent a078bd4 commit c79012f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions files/group_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from pathlib import Path

folder_to_sort = Path("/Users/bradleyyeo/Downloads")
file_folder_mapping = {
".png": "Photos",
".jpg": "Photos",
".jpeg": "Photos",
".JPG": "Photos",
".pdf": "PDFs",
".mp4": "Videos",
".mp3": "Music",
".zip": "Bundles",
".epub": "Books",
".csv": "Excel",
".xlsx": "Excel",
".pptx": "Slides",
".ppt": "Slides",
".docx": "Word",
".pem": "Credentials"
}
for file in folder_to_sort.glob("*"):
ext = file.suffix
if ext in file_folder_mapping:
dest = folder_to_sort / file_folder_mapping[ext]
if not dest.exists():
dest.mkdir()
file.rename(dest / file.name)

0 comments on commit c79012f

Please sign in to comment.