Skip to content

Commit 09dfd43

Browse files
committed
Adding Python Automater
1 parent a03b1eb commit 09dfd43

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

Folder-Automater

-1
This file was deleted.

Folder-Automater/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Folder - Automater
2+
3+
A Script Which Groups All Particular Files in a Folder to Their Respective Extensions Type

Folder-Automater/automateAll.py

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import os
2+
import shutil
3+
4+
os.chdir('/home/nopc/Downloads/SCRAP DOWNLOAD')
5+
6+
def move_pdf ():
7+
path_to_new_folder = os.getcwd() + '/PDFINHERE'
8+
for f in os.listdir():
9+
if f.endswith('.pdf'):
10+
current_file = os.getcwd() + '/'+ f
11+
shutil.move(current_file, path_to_new_folder)
12+
print("Success")
13+
14+
list_having_all_extensions = []
15+
unique_extensions = []
16+
17+
def findall () :
18+
for f in os.listdir():
19+
ch = f.split('.')
20+
if len(ch) == 2:
21+
list_having_all_extensions.append(ch[1])
22+
removing_duplicates()
23+
24+
def removing_duplicates ():
25+
unique_extensions = list(dict.fromkeys(list_having_all_extensions))
26+
print(unique_extensions)
27+
28+
def combining_all_pictures () :
29+
new_folder_path = os.getcwd() + '/Photos'
30+
#os.mkdir(new_folder_path)
31+
for f in os.listdir():
32+
ch = f.split('.')
33+
if ch[-1] == 'jpeg' or ch[-1] == 'png' or ch[-1] == 'jpg' or ch[-1] == 'obj'or ch[-1] == 'JPEG':
34+
current_file = os.getcwd() + '/'+ f
35+
shutil.move(current_file, new_folder_path)
36+
print("Success")
37+
38+
def combining_all_linux_and_windows_file () :
39+
new_folder_path = os.getcwd() + '/Linux_And_Temp_Executable_Files'
40+
#os.mkdir(new_folder_path)
41+
for f in os.listdir():
42+
ch = f.split('.')
43+
if ch[-1] == 'bin' or ch[-1] == 'deb' or ch[-1] == 'exe' or ch[-1] == 'zip' or ch[-1] == 'rpm' or ch[-1] == 'gz' or ch[-1] == 'xz':
44+
current_file = os.getcwd() + '/'+ f
45+
shutil.move(current_file, new_folder_path)
46+
print("Success")
47+
48+
49+
def combining_all_ppts_and_doc () :
50+
new_folder_path = os.getcwd() + '/PPTS_AND_DOCS'
51+
#os.mkdir(new_folder_path)
52+
for f in os.listdir():
53+
ch = f.split('.')
54+
if len(ch) == 2:
55+
if ch[1] == 'doc' or ch[1] == 'odt' or ch[1] == 'ppt' or ch[1] == 'pptx':
56+
current_file = os.getcwd() + '/'+ f
57+
shutil.move(current_file, new_folder_path)
58+
print("Success")
59+
60+
61+
findall()
62+
move_pdf()
63+
combining_all_pictures()
64+
combining_all_linux_and_windows_file()
65+
combining_all_ppts_and_doc()

0 commit comments

Comments
 (0)