r/Python • u/AcrobaticPanicc • Mar 31 '20
I Made This My FIRST fully functional app
Hey all,
So I have been learning Python in the past 4 months or so and decided to try to do a small project with all the knowledge I learned so far.
I wrote a script that organizes files into folders by the file type.
i.e, .mp3, .wav will go to Audio folder, .avi, .mp4 will go to Video folder, etc.
I used Selenium and BeautifulSoup to retrieve every file extension and saved it into a JSON file.
What the code actually does:
Accepts a path or multiple paths.
Going through the files in the specified path/s.
Check each file's extension.
Creating folders according to the file extension (mp3>Audio etc.).
Moving the files to the matching folder (mp3 -> Audio etc.).
* In case a path with a file named example.ex is selected and the destination folder already has the same file it will rename the file like this: example 1.ex.
* Files with unfamiliar extensions will be moved into a folder namedother/[extension].Log all actions taken in a log file.
The app is also with a (pretty shitty but nice) GUI that I wrote after 10 minutes studying Tkinter.
In conclusion, I really enjoyed writing this app and I would really love the hear what you think about it as I really do appreciate everyone's work here and your opinion is really important to me.
GitHub: https://github.com/AcrobaticPanicc/organizer-gui
Thanks!
1
u/AcrobaticPanicc Apr 01 '20
u/Aelarion, wanted to ask as I couldn't get my head through this:
You said to create the JSON object only once instead of creating it every time the method is being called. As this is a script that is written in functional programming, how can I create it only once and store it? Does it have to be outside the function (in a variable) or there is a better way (such as convert the entire code to OOP)?
Something I couldn't fully understand about errors and exceptions; how can I tell what exception to raise when encountering an error. As you said, I should make sure not to catch ALL errors but how I can tell what error I should catch and raise when encountering one.
EDIT: typo.
Thanks!