Skip to content

Commit ff79b95

Browse files
authoredJun 21, 2023
Add files via upload
1 parent 954c5b8 commit ff79b95

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed
 

‎Filetutorial.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22
import os
3-
import shutil
3+
44
filelist = []
55

66
#path of the the folder you want to sort
7-
src = (r'C:\Users\'UserName'\Downloads')
7+
src = "in/"
88

99

1010
extOnly = set()
@@ -30,6 +30,6 @@
3030
for file in filelist:
3131
extFinal = file.split('.')
3232
try:
33-
os.rename(file, extFinal[1] + "_Files/" + file)
34-
except (OSError, IndexError):
35-
continue
33+
os.rename(src + file, extFinal[1] + "_Files/" + file)
34+
except Exception as e:
35+
print(e)

‎clean.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
rm -rf out/
2+
mkdir out
3+
touch in/test.txt
4+
touch in/test2.txt
5+
touch in/test.py
6+
touch in/test2.py

‎order.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import os
2+
3+
indir = "in/"
4+
outdir="out/"
5+
6+
files=set()
7+
for file in os.listdir(indir):
8+
if "." in file:
9+
files.add(file)
10+
11+
for e in [e.split(".")[1] for e in files]:
12+
if not os.path.exists(outdir+"/"+e): os.mkdir(outdir+"/"+e)
13+
14+
for f in files:
15+
os.rename(indir+f, outdir + str(f.split(".")[1])+ "/" + f)

0 commit comments

Comments
 (0)
Please sign in to comment.