-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile_organizer_copy.py
More file actions
27 lines (18 loc) · 838 Bytes
/
file_organizer_copy.py
File metadata and controls
27 lines (18 loc) · 838 Bytes
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
import os
import shutil
def file_organizer(source, image_destination, doc_destination):
# Create directories if it doesn't exist
if image_destination is not None:
os.makedirs(image_destination, exist_ok=True)
if doc_destination is not None:
os.makedirs(doc_destination, exist_ok=True)
for file in os.listdir(source):
# Skip directories
if os.path.isdir(os.path.join(source, file)):
continue
if file.endswith(".jpg") and image_destination is not None:
shutil.copy(os.path.join(source, file), image_destination)
elif file.endswith(".pdf") and doc_destination is not None:
shutil.copy(os.path.join(source, file), doc_destination)
print("Files successfully arranged✅")
file_organizer("C:\\Users\\user\\Desktop\\file organizer", None, "C:\\Users\\user\\Downloads\\Favour")