diff --git a/File-Categorizer/README.md b/File-Categorizer/README.md new file mode 100644 index 0000000..2012da2 --- /dev/null +++ b/File-Categorizer/README.md @@ -0,0 +1,18 @@ +

File Organizer

+ +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) + +

Here, I will publish my Personal Python Projects whenever I get the time.

+ +## Connect with me + + +   + + +   diff --git a/File-Categorizer/file-categorizer.py b/File-Categorizer/file-categorizer.py new file mode 100644 index 0000000..b04666e --- /dev/null +++ b/File-Categorizer/file-categorizer.py @@ -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 \ No newline at end of file diff --git a/File-Categorizer/screenshot.png b/File-Categorizer/screenshot.png new file mode 100644 index 0000000..d99bacb Binary files /dev/null and b/File-Categorizer/screenshot.png differ