└── python project.txt /python project.txt: -------------------------------------------------------------------------------- 1 | import os 2 | import shutil 3 | 4 | path = input("Enter path:") 5 | files = os.listdir(path) 6 | 7 | for file in files: 8 | filename,extension = os.path.splitext(file) 9 | extension = extension[1:] 10 | 11 | if os.path.exists(path+'/'+extension): 12 | shutil.move(path+'/'+file, path+'/'+extension+'/'+file) 13 | else: 14 | os.makedirs(path+'/'+extension) 15 | shutil.move(path+'/'+file, path+'/'+extension+'/'+file) 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | C:\Users\selva\Desktop\File --------------------------------------------------------------------------------