Building an Automated File Sorter in File Explorer using Python | Python Projects for Beginners

  Рет қаралды 69,274

Alex The Analyst

Alex The Analyst

Күн бұрын

Пікірлер: 84
@ChronicleContent
@ChronicleContent Жыл бұрын
shutil is called "shell utilities" because it allows you to perform various file-related tasks that are similar to the commands that you might use in a Unix shell, such as copying, moving, renaming, and deleting files and directories.
@jeancazilus8314
@jeancazilus8314 Жыл бұрын
Thanks for the explanation !! Very informative 👌🏾
@nesternunez8430
@nesternunez8430 Жыл бұрын
Instead of getting rid of the \ in lieu of the /, you can add an additional \\ at the the of the path in order to make it an escape character. Alex, this video was awesome!
@arnoldochris5082
@arnoldochris5082 Жыл бұрын
This is a very good tutorial, I appreciate all the work you put into each video I modified the program to extract the file extensions of each file. - Create a folder based on each individual unique extension - (used sets) - Move files to their respective folders based on their extensions. - I hope I learn app development so I can create this into a full application for use.
@Intel626
@Intel626 Жыл бұрын
It has been 5 years since I coded but I finally did a step one by following your tutorial. I am super thankful for it!
@Andrei_Neo
@Andrei_Neo Жыл бұрын
Alex! Another project is completed! Every new step in your bootcamp increases my curiosity to go further. I am really into it. :) Again, many thanks for your time and knowledge. I have never been so involved in IT education as I am now with your teaching approach
@carocahyadi94
@carocahyadi94 Жыл бұрын
Hey Alex! I know you get so much of these comments already but I just wanna say thank you for creating these tutorials! I've been faithfully following your Excel, Tableau and Python tutorial and they all really help me understand better than some paid courses I've been through. Cheers!
@sj1795
@sj1795 11 ай бұрын
This was a FANTASTIC video! I learned SO much and I loved how you walked us through all the steps like you do in all your videos. You're a pro and an EXCELLENT teacher! As always, THANK YOU ALEX!!
@Working800
@Working800 Жыл бұрын
When I was learning python last year I did this to myself, cause I needed it for my downloads folder, you did it in 16 minutes I was there for like 3 weeks hahaha
@AbdessamadALIRABAH
@AbdessamadALIRABAH Жыл бұрын
A small program that helps presenting all available extensions in our "listdir" : def extension(x): i = 0 while i < len(x) : if x[i] == "." : return x[i+1:] i=i+1 return "" extension_list = list(map(exsention, a)) extension_set=set(extension_list) print(extension_set) # is the list resulted from the fonction os.listdir
@clovisstanford6515
@clovisstanford6515 10 ай бұрын
This video is amazing I used this algorithm to separate the vidoes and images to different folders with learning and without effort . Thank you 😆😆
@ivanko-nebo
@ivanko-nebo Жыл бұрын
Hi Alex! I`ve tried to do something similar based on your video. The task I've set was: I have a lot of files which names have identical beginning in my Downloads and I have tried to move them all to a single folder. Here's what I`ve tried to do and it has worked (not from the first try, to tell the truth, but still). import os, shutil path = r"C:/Users/idemianenko/Downloads/" file_name = os.listdir(path) os.makedirs(path + 'Credit notes') for file in file_name: if 'invoice_print_' in file: shutil.move(path + file, path + 'Credit notes/' + file) That's why your channel is a box of wonders for me! Thank you for your content and wish you lots of luck!
@heritage1834
@heritage1834 Жыл бұрын
This is nice 👍
@courtenayboyle4329
@courtenayboyle4329 Жыл бұрын
awesome!
@rsukut5866
@rsukut5866 Жыл бұрын
That's pretty fantastic, and seems like a perfect real-life application! Thank you for sharing this.
@jh1896
@jh1896 3 ай бұрын
This is so awesome. I feel like a magician! Thanks, Alex!
@saidimbondela9158
@saidimbondela9158 Жыл бұрын
This tells me python is such a powerful tool everyone must learn
@KANOJIARICHA
@KANOJIARICHA 7 ай бұрын
This is very nice way to sort all the files in the folder. I modified the program a little, and allowed it to read all files from the folder and generate the folder name based on the file extension. This way we can eliminate the hard code folder names. I have also used os.path.join() method to join the file paths without using '/' , which is again a good practice when working with files.
@aisyahmokhtar4616
@aisyahmokhtar4616 6 ай бұрын
if you dont mind, can you share the script that allows you to not hard code the folder names and just generate the folder name based on the file extension? i would love to learn this method too. thank you for sharing!
@neildelacruz6059
@neildelacruz6059 Жыл бұрын
Excellent, simple easy tutorial, Thanks!
@CaitlinLemon-s6v
@CaitlinLemon-s6v Жыл бұрын
If you're a mac user, I'd expect to hit a snaffu. I personally get a * next to the file name and when I print. I think it's because the mac file paths use a bunch of "%20".
@chintalapatisriharshavarma2575
@chintalapatisriharshavarma2575 6 ай бұрын
You are amazing , your my super hero. This playlist/Bootcamp is very helpfull 🙂
@Charlay_Charlay
@Charlay_Charlay Жыл бұрын
I got it to work!!! Thanks Alex!
@cozimbatman4100
@cozimbatman4100 4 ай бұрын
a fun project would be to read the extensions for each file from file_name and creating the folder(if not exists) and then move the files into the respective(if not exists)
@rakibhasanrahad6994
@rakibhasanrahad6994 9 ай бұрын
here's a better version where you dont have to hard code the folder names and file types : import os import shutil # Path where the files are located and where folders will be created path = r"......../" # Get all file names in the specified directory file_names = os.listdir(path) # Initialize a set to hold unique file extensions file_extensions = set() # Populate the set with file extensions (in lowercase to avoid duplicates due to case differences) for file_name in file_names: if os.path.isfile(os.path.join(path, file_name)): # Ensure it's a file, not a directory extension = os.path.splitext(file_name)[1].lower() if extension: # Ensure there is an extension file_extensions.add(extension) # Create folders for each file type if they don't already exist for ext in file_extensions: folder_name = ext[1:] + " files" # Remove the dot from extension and add ' files' folder_path = os.path.join(path, folder_name) if not os.path.exists(folder_path): os.makedirs(folder_path) # Move files to their respective folders for file_name in file_names: # Skip directories if os.path.isdir(os.path.join(path, file_name)): continue # Get the file extension and corresponding folder name file_extension = os.path.splitext(file_name)[1].lower() if file_extension: folder_name = file_extension[1:] + " files" target_folder_path = os.path.join(path, folder_name) # Full path for the file's current location and the target location current_file_path = os.path.join(path, file_name) target_file_path = os.path.join(target_folder_path, file_name) # Move the file if it's not already in the target folder if not os.path.exists(target_file_path): shutil.move(current_file_path, target_file_path)
@Bac2277
@Bac2277 Жыл бұрын
Hey Alex, I do not find live server in visual studio extensions. How should I get it?
@Mrnafuturo
@Mrnafuturo Жыл бұрын
was a great one, but I would rather refactor the code in a way to avoid getting too many if statements spread out in the code, just to keep redundancy away from it. Subscribed!
@Kaura_Victor
@Kaura_Victor 8 ай бұрын
I've written these codes as it is on the tutorial but it's not running as expected. It's giving me a lot of error messages.
@kaylaesezobor9258
@kaylaesezobor9258 8 ай бұрын
It's not even giving me anything
@ToVods
@ToVods Жыл бұрын
Hi Alex I would like to thank you for all of the effords you went through to help everyone.I really appriciate you.I don't live in US but Do you think with a portfolio that has up to 10 different projects, i can land an interview on linkedin for a remote job?
@ruthshada2752
@ruthshada2752 Жыл бұрын
In the same situation here, I don’t live in the us and trying to land interviews for a remote job. How is it going for you so far ?
@lil_dejix9144
@lil_dejix9144 4 ай бұрын
I'm just wondering won't it be more dynamic to make the range in the for loop Len(folder_names) ?
@sarkersaadahmed
@sarkersaadahmed 9 ай бұрын
8:05 you can alsso use \\ instead of /
@frothylube491
@frothylube491 Жыл бұрын
Hey Alex! I know this isn’t exactly related to the video but I have a question. Do you think a company would hire someone as a data analyst, if all they had were mere basics? Simply they didn’t have a degree in the area, perhaps a certification, but they had a driving spirit to learn. Or are most people, even for entry level positions, expecting you to just drop into the seat and go off with little to no extra help?
@atxvet
@atxvet Жыл бұрын
I just happened to pop in and saw your question, so let me take a crack at answering as an Old who hires people. Short answer: Yes. What sets an entry level/junior analyst candidate apart is not their technical abilities but their critical thinking and CURIOSITY. If I give you a pile of data, I want your eyes to light up at the prospect of EDA. I expect whatever you give me to be full of mistakes and flawed logic -- and that's FINE, as long as I see that the lights are on upstairs and you have asked the data lots of interesting questions. Critical thinking, curiosity, interested, and interesting. That's what I'm after. Good luck!
@frothylube491
@frothylube491 Жыл бұрын
@@atxvet I appreciate the response! I just finished the Google certification, and I’m working on doing more projects. My worry is that since I’m still only 5 months on from beginning to learn Data Analytics is that no one will give me a chance. All I’m really wanting is for a hiring manager to see my interest and drive then give me a shot, even if my skills are very…..beginner. Help train me with someone by my side and i will give 200% on everything to prove I’m taking this seriously. I just don’t know anyone, personally, in the field to ask any questions, so I’ve been hesitant on replying.
@kaylaesezobor9258
@kaylaesezobor9258 8 ай бұрын
8:31 mine isn't printinh out anything or making any folder
@swethareddy2270
@swethareddy2270 4 ай бұрын
check wheather the path is crt or not .(path = r"......./" )
@TheDanzo96
@TheDanzo96 Жыл бұрын
When you had the 'Else' statement and it returned the message 4 times would that have been because of the 3 folders? I think it may have counted those as a "file" in the folder
@sagarpatel2630
@sagarpatel2630 5 ай бұрын
It happened because files were already moved into folders and if/elif were returning false due to the "and" conditions.
@RonanJozwiak
@RonanJozwiak 3 ай бұрын
Hi Alex! I really appreciate all these videos that you've posted. I'm still getting a bunch of errors with this though, and I'm not able to see on the video where I'm making errors. Is this posted on your github somewhere? I'm sure I'm missing punctuation or something that I'm just not able to see on the video.
@chaayoub5360
@chaayoub5360 Жыл бұрын
thank you. but i think you forget to add video about how to clean data using python
@KarmenKaur-k5h
@KarmenKaur-k5h Жыл бұрын
Hi Alex, Could you please tell how can I do this on mac - what will be the path ? Thank you.
@CaitlinLemon-s6v
@CaitlinLemon-s6v Жыл бұрын
Right click on the file and select "get info." However, make sure you've enabled "show path" under "view."
@anuraja454
@anuraja454 Ай бұрын
hi, I am getting an "Argument of type bool is not iterable " error while moving files to a folder. does anyone have a solution?? please help me here is my code for file in file_names: if '.ppt' in file not in os.path.exists(path + 'ppt files/' + file): shutil.move(path + file, path + 'ppt files/' + file)
@Mohammad-tw7cq
@Mohammad-tw7cq Жыл бұрын
The PCWizKid mouse cursor is a classic.
@falahoudinesaid6973
@falahoudinesaid6973 7 ай бұрын
hello Alex ? Thank you for the tutorial. One question please what about PDF file?
@wahyuprasetyo6098
@wahyuprasetyo6098 5 ай бұрын
1. add 'PDF Files' in folder_name list 2. change the range to (0, 4) 3. add to loop: elif '.pdf' in file and not os.path.exists(path + 'PDF Files/' + file): shutil.move(path + file, path + 'PDF Files/' + file)
@JD_2
@JD_2 Жыл бұрын
great content
@victoradekunlecom
@victoradekunlecom Жыл бұрын
Damn! Alex is so real. Can we write a program to automatically detect the file formats, create folders and sort them accordingly? Because I feel it could be difficult to manually detect and name the folders if the list is endless. Sounds like a clustering thing in machine learning but I'm not sure. Please what do you think?
@Bomyism
@Bomyism Жыл бұрын
I've asked ChatGPT to do it and voilà: import os import shutil # specify the directory you want to sort source_directory = r"C:\Users\Username\Documents\Sort Me" try: # get a list of all files in the source directory file_list = os.listdir(source_directory) # create a folder for each file extension for file_name in file_list: file_extension = os.path.splitext(file_name)[1][1:] destination_folder = os.path.join(source_directory, file_extension) if not os.path.exists(destination_folder): os.makedirs(destination_folder) # move the file to the appropriate folder source_path = os.path.join(source_directory, file_name) destination_path = os.path.join(destination_folder, file_name) shutil.move(source_path, destination_path) except Exception as e: print(f"An error occurred while sorting the files: {e}")
@TrickzHD
@TrickzHD Жыл бұрын
How would I go a step further that it goes automatically every like day or so?
@victoradekunlecom
@victoradekunlecom Жыл бұрын
Also, I had issues doing the amazon web-scrapping project you posted about a year ago because a lot had changed in the webpage source. I asked for help but I didn't get a response, we understand you're busy (we don't your time for granted or feel entitled to it) but do you plan to do another web scrapping project to include in the Free Boot Camp?
@jamescao4128
@jamescao4128 Жыл бұрын
What issue u gave, I was able to do it with a different Amazon pahe
@jamescao4128
@jamescao4128 Жыл бұрын
*have just shoot me a DM. I'll help you out , I just finished mine yesterday
@victoradekunlecom
@victoradekunlecom Жыл бұрын
@@jamescao4128 Thank you
@freemanjavascreen9789
@freemanjavascreen9789 Жыл бұрын
@@jamescao4128 can you search me up on linnkedn first name and last name. Couldn't find you
@freemanjavascreen9789
@freemanjavascreen9789 Жыл бұрын
Victor Adekunle
@shaaniplays9931
@shaaniplays9931 Жыл бұрын
Hey alex would you be kind enough to confirm if your data boot camp covers all the basics of those tools so after that i can move on to intermediate stuff. ☺️ Thanks
@rajeshgautam-k2r
@rajeshgautam-k2r Жыл бұрын
@Alex how do i connect with you?
@bufagp648
@bufagp648 Жыл бұрын
Hi Alex it's not working out is there any other way to do this
@peterdenes6353
@peterdenes6353 Жыл бұрын
Hey, great video! I am kinda new to programming and I would like to ask for help with two questions if anyone sees this: 1: When defining the if statement for the for loop, I tried to add multiple formats to a given folder like: if ".jpg" or ."png" in file and...( the rest as in the video) but for some reason this made all files and folders copy into the destination directory, which I am not able to understand why? 2: It worked for me in Jupiter, but I first tried to do it in VS code with an Anaconda virtual environment setup, but for some reason shutil couldn't be accessed. OS worked fine. I have worked with different packages before, so I am not sure why this one doesn't like my virtual environment. Thank you for reading all through this and for your help in advance.
@nafisansari5854
@nafisansari5854 11 ай бұрын
Hey Man, there are a few issues with the VS code, try using the python terminal in the VS code instead of the Jupyter Notebook extension in it. This could an issue of Code Runner extension. You can go through a few tutorials for Code Runner issue in VS code. Hope this helps.
@iyaszawde
@iyaszawde 9 ай бұрын
Thanks a lot ❤️, could anyone tell me how to make an execution for this script each day, please!
@ROZA99090
@ROZA99090 Жыл бұрын
Im not able to make file folders
@garvinasimwe
@garvinasimwe Жыл бұрын
Hi Alex, I am getting an error that says NameError: name 'os' is not defined. Any help is greatly appreciated.
@delightogwor3350
@delightogwor3350 Жыл бұрын
did you pip install os
@bufagp648
@bufagp648 Жыл бұрын
@@delightogwor3350 how do you install os
@uplifthabesha754
@uplifthabesha754 Жыл бұрын
Do you think this will be good project to put in our portfolio?
@AlexTheAnalyst
@AlexTheAnalyst Жыл бұрын
I do - it's a pretty neat project :) Something I've used in my job before
@thefacelessone74
@thefacelessone74 9 ай бұрын
this video is 12mins of messing up code and 4mins of how to code a automatic file organizer
@uchindamiphiri1381
@uchindamiphiri1381 Жыл бұрын
Suprisingly my fles are not moved
@uchindamiphiri1381
@uchindamiphiri1381 Жыл бұрын
Correction: It has worked after putting two forward slashes on my folder names when operating if statements
@economicblast
@economicblast Жыл бұрын
bro who codes like this. 😭
@davidjukebox
@davidjukebox Жыл бұрын
I've been going through your videos. This one comes out of nowhere and was painful to watch. What does this have to do with Data Analysis? I didn't follow your work/instructions, was lost within the first section - actually, was lost from a few videos back and have been confused. This could turn into hours of figuring out what you were doing.... and for what?!?! Moving pics around you could have just dragged into a new folder. Insane... why isn't any of this relevant?
@peterbelanger4094
@peterbelanger4094 10 ай бұрын
What is this "jupyter" stuff you are coding on? some online "collab tool?" ..It totally throws me off, why not show us normally, locally, on a command prompt? Some of us do not know or need these cloud based team collab nonsense. We just want t learn Python for ourselves, not in college or some corporate drone.
Reading in Files in Pandas | Python Pandas Tutorials
19:17
Alex The Analyst
Рет қаралды 205 М.
Scraping Data from a Real Website | Web Scraping in Python
25:23
Alex The Analyst
Рет қаралды 528 М.
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
3 Python Automation Projects - For Beginners
53:11
Tech With Tim
Рет қаралды 557 М.
5 Amazing Ways to Automate Your Life using Python
18:40
Internet Made Coder
Рет қаралды 268 М.
Data Cleaning in Pandas | Python Pandas Tutorials
38:37
Alex The Analyst
Рет қаралды 344 М.
Functions in Python | Python for Beginners
12:44
Alex The Analyst
Рет қаралды 69 М.
Data Types in Python | Python for Beginners
21:58
Alex The Analyst
Рет қаралды 132 М.
ASMR Programming - Spinning Cube - No Talking
20:45
Servet Gulnaroglu
Рет қаралды 4,2 МЛН
REST API Crash Course - Introduction + Full Python API Tutorial
51:57
Building a BMI Calculator with Python | Python Projects for Beginners
14:23
How to Use SQL with Excel using Python
16:52
SATSifaction
Рет қаралды 123 М.
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН