Skip to content

Commit

Permalink
add filesorting script
Browse files Browse the repository at this point in the history
  • Loading branch information
kmgrime committed Oct 10, 2023
1 parent fa8a9c9 commit e5d8a14
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions scripts/filesorting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# imports
import os
import glob
import shutil
from os import path

# what files with which extensions to move
filename=glob.glob("C:/Users/Aleti Sunil/Downloads/*")
documents=['.pdf','.docx','.doc','.txt']
media=['.jpeg','.jpg','.svg','.png','.PNG','.mp4','.mp3']
setupFiles=['.exe','.msi']
compressedFiles=['.zip']
files=['.apk']

# file locations
DocumentsLocation='C:/Users/Aleti Sunil/Downloads/documents'
mediaLocation='C:/Users/Aleti Sunil/Downloads/media'
setupFilesLocation='C:/Users/Aleti Sunil/Downloads/setupFiles'
compressedFilesLocation='C:/Users/Aleti Sunil/Downloads/compressedFiles'
FilesLocation='C:/Users/Aleti Sunil/Downloads/Files'

# script for moving the files corresponding to the extensions
for file in filename:
if os.path.splitext(file)[1] in documents:
if(path.exists(DocumentsLocation)):
shutil.move(file,DocumentsLocation)
else:
os.mkdir(DocumentsLocation)
shutil.move(file,DocumentsLocation)
if os.path.splitext(file)[1] in media:
if(path.exists(mediaLocation)):
shutil.move(file,mediaLocation)
else:
os.mkdir(mediaLocation)
shutil.move(file,mediaLocation)
if os.path.splitext(file)[1] in setupFiles:
if(path.exists(setupFilesLocation)):
shutil.move(file,setupFilesLocation)
else:
os.mkdir(setupFilesLocation)
shutil.move(file,setupFilesLocation)
if os.path.splitext(file)[1] in compressedFiles:
if(path.exists(compressedFilesLocation)):
shutil.move(file,compressedFilesLocation)
else:
os.mkdir(compressedFilesLocation)
shutil.move(file,compressedFilesLocation)
if os.path.splitext(file)[1] in files:
if(path.exists(FilesLocation)):
shutil.move(file,FilesLocation)
else:
os.mkdir(FilesLocation)
shutil.move(file,FilesLocation)

0 comments on commit e5d8a14

Please sign in to comment.