Skip to content

Add File Categorizer #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from Oct 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions File-Categorizer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<h1>File Organizer</h1>

Basically assembles files that share the same extension into a folder.

![screenshot](https://user-images.githubusercontent.com/107259402/193411368-360aef5e-1b81-481f-8272-f484ac81b787.png)


![Personal-Python-Projects](https://socialify.git.ci/KrishGaur1354/Personal-Python-Projects/image?font=Source%20Code%20Pro&language=1&name=1&owner=1&pattern=Circuit%20Board&theme=Dark)

<h3><i>Here, I will publish my Personal Python Projects whenever I get the time.</i></h3>

## Connect with me
<a href="https://twitter.com/ThatOneKrish">
<img width="30px" src="https://www.vectorlogo.zone/logos/twitter/twitter-official.svg" />
</a>&ensp;
<a href="https://www.instagram.com/ThatOneKrish/">
<img width="30px" src="https://www.vectorlogo.zone/logos/instagram/instagram-icon.svg" />
</a>&ensp;
27 changes: 27 additions & 0 deletions File-Categorizer/file-categorizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os
import shutil

ld = os.listdir()

for file in ld:
if not '.' in file or os.path.isdir(file):
continue
else:
if file == os.path.basename(__file__):
continue
ext = file.split('.')[-1]
directory = ext.upper()+'s'

if directory in ld:
print(f'Skipping {directory} directory...')
else:
print(f'Creating {directory} directory...')
os.mkdir(directory)
ld.append(directory)

try:
shutil.move(file, directory)
print(f'File {file} moved successfully!\n')
except shutil.Error as e:
print(e)
continue
Binary file added File-Categorizer/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.