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