Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions BasicPythonScripts/Folder Content Sorter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Folder Content Sorter

## Aim

To sort all the files of folder properly

## Purpose

To locate the files as per their extension or type.

## Short description of package/script

- Here we first fetch the path of the current folder and than get the extension of each file and then sort the file according to that
-For example ,if extensions are .pdf , .docx then it will go to documents folder simillarly for images>.jpg,.png,.gif ,for videos > .mp4,.wmv and for apps>.apk,.exe .


- List out the libraries imported > os , shutil


## Workflow of the Project

- First have the script in the same folder in whuch you wanted to sort the files and then run the script so as a result different folders will be formed accordingly.


## Setup instructions
- Fisrt install the libraries and then run the script so all the files will be allocated in images,videos,apps and documents folder respectively.


## Output
![image](Images/before_running(folder_content_sorter).png)
![image](Images/after_running(folder_content_sorter).png)
![image](Images/output(folder_content_sorter).png)


## Author(s)

Neel Shah
37 changes: 37 additions & 0 deletions BasicPythonScripts/Folder Content Sorter/folder_content_sorter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import os
import shutil

#getting path of current folder/directory
current_dir = os.path.dirname(os.path.realpath(__file__))

for filename in os.listdir(current_dir):
#for images
if filename.endswith(('.jpg', '.png', '.gif')):
if not os.path.exists("Images"):
os.makedirs('Images')
shutil.copy(filename, 'Images')
os.remove(filename)
print('Images folder done')
#for documents
if filename.endswith(('.pdf', '.docx')):
if not os.path.exists("Documents"):
os.makedirs('Documents')
shutil.copy(filename, 'Documents')
os.remove(filename)
print('Documents folder done')
#for apps or softwares
if filename.endswith(('.apk', '.exe')):
if not os.path.exists("Apps"):
os.makedirs('Apps')
shutil.copy(filename, 'Apps')
os.remove(filename)
print('Apps folder done')
#for videos
if filename.endswith(('.mp4', '.wmv')):
if not os.path.exists("Videos"):
os.makedirs('Videos')
shutil.copy(filename, 'Videos')
os.remove(filename)
print('Videos folder done')
#after completing the task printing all done
print('all done')
3 changes: 3 additions & 0 deletions BasicPythonScripts/Folder Content Sorter/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Libraries used:
- shutil
- os