File tree Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ <h1 >File Organizer</h1 >
2
+
3
+ Basically assembles files that share the same extension into a folder.
4
+
5
+ ![ screenshot] ( https://user-images.githubusercontent.com/107259402/193411368-360aef5e-1b81-481f-8272-f484ac81b787.png )
6
+
7
+
8
+ ![ Personal-Python-Projects] ( https://socialify.git.ci/KrishGaur1354/Personal-Python-Projects/image?font=Source%20Code%20Pro&language=1&name=1&owner=1&pattern=Circuit%20Board&theme=Dark )
9
+
10
+ <h3 ><i >Here, I will publish my Personal Python Projects whenever I get the time.</i ></h3 >
11
+
12
+ ## Connect with me
13
+ <a href =" https://twitter.com/ThatOneKrish " >
14
+ <img width="30px" src="https://www.vectorlogo.zone/logos/twitter/twitter-official.svg" />
15
+ </a >&ensp ;
16
+ <a href =" https://www.instagram.com/ThatOneKrish/ " >
17
+ <img width="30px" src="https://www.vectorlogo.zone/logos/instagram/instagram-icon.svg" />
18
+ </a >&ensp ;
Original file line number Diff line number Diff line change
1
+ import os
2
+ import shutil
3
+
4
+ ld = os .listdir ()
5
+
6
+ for file in ld :
7
+ if not '.' in file or os .path .isdir (file ):
8
+ continue
9
+ else :
10
+ if file == os .path .basename (__file__ ):
11
+ continue
12
+ ext = file .split ('.' )[- 1 ]
13
+ directory = ext .upper ()+ 's'
14
+
15
+ if directory in ld :
16
+ print (f'Skipping { directory } directory...' )
17
+ else :
18
+ print (f'Creating { directory } directory...' )
19
+ os .mkdir (directory )
20
+ ld .append (directory )
21
+
22
+ try :
23
+ shutil .move (file , directory )
24
+ print (f'File { file } moved successfully!\n ' )
25
+ except shutil .Error as e :
26
+ print (e )
27
+ continue
You can’t perform that action at this time.
0 commit comments