Skip to content

Instantly share code, notes, and snippets.

@ChamodDamitha
Last active December 29, 2017 11:22
Show Gist options
  • Save ChamodDamitha/099e8c27d65b48e478e9dfc28b0bccdb to your computer and use it in GitHub Desktop.
Save ChamodDamitha/099e8c27d65b48e478e9dfc28b0bccdb to your computer and use it in GitHub Desktop.
import os
from shutil import copyfile
types = []
files = [f for f in os.listdir('.') if os.path.isfile(f)]
for f in files:
ext = f.split('.')[-1]
dirr = 'Chategorized/' + ext + "-files"
if ext not in types:
if not os.path.exists(dirr):
os.makedirs(dirr)
copyfile(f, dirr + '/' + f)
@ChamodDamitha
Copy link
Author

This script will order the files of the directory which include the script based on the file types. Separate folders will be created for each file type. A main folder named 'Chategorized' will be created which includes the ordered directories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment