├── .gitignore ├── Clean_Sorting.py ├── Clean_Sorting.pyw └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | local_settings.py 56 | 57 | # Flask stuff: 58 | instance/ 59 | .webassets-cache 60 | 61 | # Scrapy stuff: 62 | .scrapy 63 | 64 | # Sphinx documentation 65 | docs/_build/ 66 | 67 | # PyBuilder 68 | target/ 69 | 70 | # Jupyter Notebook 71 | .ipynb_checkpoints 72 | 73 | # pyenv 74 | .python-version 75 | 76 | # celery beat schedule file 77 | celerybeat-schedule 78 | 79 | # SageMath parsed files 80 | *.sage.py 81 | 82 | # dotenv 83 | .env 84 | 85 | # virtualenv 86 | .venv 87 | venv/ 88 | ENV/ 89 | 90 | # Spyder project settings 91 | .spyderproject 92 | .spyproject 93 | 94 | # Rope project settings 95 | .ropeproject 96 | 97 | # mkdocs documentation 98 | /site 99 | 100 | # mypy 101 | .mypy_cache/ 102 | -------------------------------------------------------------------------------- /Clean_Sorting.py: -------------------------------------------------------------------------------- 1 | #28/8/17 2 | # Sorting files in a directory according to their extensions. 3 | import sys 4 | import re 5 | import os 6 | from tkinter import* 7 | import tkinter.filedialog 8 | import tkinter.messagebox 9 | 10 | root = Tk() 11 | root.withdraw() 12 | temp_file = tkinter.filedialog.askdirectory(parent= root, initialdir =os.getcwd(),title="Select Folder to " 13 | "be Cleanly Sorted") 14 | #print(temp_file) 15 | path = temp_file+"/"#Your path here 16 | #print(path) 17 | files = os.listdir(path) 18 | #print(os.listdir(path)) 19 | 20 | ext = [] 21 | 22 | for k in files: 23 | 24 | file_ext = os.path.splitext(k)[1] 25 | #print(file_ext) 26 | pattern = r'([\w]+)' 27 | match = re.search(pattern,file_ext) 28 | if match: 29 | folder_name = match.group().upper() 30 | path1 = path + folder_name 31 | #print(file_ext) 32 | if not os.path.exists(path1): 33 | os.mkdir(path1) 34 | os.chdir(path) 35 | os.system("move "+'"'+k+'"'+" "+'"'+path1+'"')#double quote embed in single colon 36 | ext.append(folder_name) 37 | 38 | if len(temp_file) > 0: 39 | tkinter.messagebox.showinfo(title="Processing Done",message="Files are cleanly sorted.") 40 | 41 | # -------------------- Completed to requirement ----------------------------- 42 | -------------------------------------------------------------------------------- /Clean_Sorting.pyw: -------------------------------------------------------------------------------- 1 | #28/8/17 2 | # Sorting files in a directory according to their extensions. 3 | import sys 4 | import re 5 | import os 6 | from tkinter import* 7 | import tkinter.filedialog 8 | import tkinter.messagebox 9 | 10 | root = Tk() 11 | root.withdraw() 12 | temp_file = tkinter.filedialog.askdirectory(parent= root, initialdir =os.getcwd(),title="Select Folder to " 13 | "be Cleanly Sorted") 14 | print(temp_file) 15 | path = temp_file+"/"#Your path here 16 | print(path) 17 | files = os.listdir(path) 18 | print(os.listdir(path)) 19 | 20 | ext = [] 21 | 22 | for k in files: 23 | print(k) 24 | file_ext = os.path.splitext(k)[1] 25 | #print(file_ext) 26 | pattern = r'([\w]+)' 27 | match = re.search(pattern,file_ext) 28 | if match: 29 | folder_name = match.group().upper() 30 | path1 = path + folder_name 31 | #print(file_ext) 32 | if not os.path.exists(path1): 33 | os.mkdir(path1) 34 | 35 | #print(path1) 36 | os.chdir(path) 37 | cmd = ' "'+k+'" ' 38 | 39 | os.system("move "+cmd+'"'+path1+'"')#double quote embed in single colon 40 | ext.append(folder_name) 41 | 42 | if len(temp_file) > 0: 43 | tkinter.messagebox.showinfo(title="Processing Done",message="Files are cleanly sorted.") 44 | 45 | # -------------------- Completed to requirement ----------------------------- 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Clean-Sorting 2 | Sorting files in a directory according to their extensions. 3 | ![image](https://a.fsdn.com/con/app/proj/clean-sorting/screenshots/ss1.png) 4 | ![image](https://a.fsdn.com/con/app/proj/clean-sorting/screenshots/ss2.png) 5 | ![image](https://a.fsdn.com/con/app/proj/clean-sorting/screenshots/ss3.png) 6 | 7 | 8 | Executable file : https://sourceforge.net/projects/clean-sorting/ 9 | --------------------------------------------------------------------------------