---
title: "Comment by James Maskell on \"Automate boring files organizing using python (Python files organizer)\" | Hashnode"
description: "Hi! Good work. I have some feedback which might help you refactor this code to make it more flexible and less open to bugs appearing There is a lot of repeated/"
url: "https://hashnode.com/posts/automate-boring-files-organizing-using-python-python-files-organizer/612d61a12858872661b9ed60/comment/6135acc292d0321a99995977"
---

[Discussion](https://hashnode.com/posts/automate-boring-files-organizing-using-python-python-files-organizer/612d61a12858872661b9ed60)

Comment [Automate boring files organizing using python (Python files organizer)](https://hashnode.com/posts/automate-boring-files-organizing-using-python-python-files-organizer/612d61a12858872661b9ed60)

[James Maskell](https://hashnode.com/@wakingupat12)

[Sep 6, 2021](https://hashnode.com/posts/automate-boring-files-organizing-using-python-python-files-organizer/612d61a12858872661b9ed60/comment/6135acc292d0321a99995977)

Hi! Good work.

I have some feedback which might help you refactor this code to make it more flexible and less open to bugs appearing

1.  There is a lot of repeated/duplicate code in your if statement. Have you thought about creating a method which performs the move file code?
2.  The code above relies on the directories in file\_folders dictionary existing. Have you thought about what would happen if those directories hadn't been created prior to the program running?
3.  The code above has the file\_folder 'types' (documents, pictures, etc) hard coded in your if statement. Have you thought about creating a method that gets the key from the file extension?
4.  Do you need both the file\_folder and file\_type dictionaries, or can you turn them into a single dictionary?

I personally would turn this into a Python class too, so that I can inject the file types, file folders and the path I'm moving files from into the class.

Happy coding!

[Budy mnvenom](https://hashnode.com/@xbudy)

[Sep 13, 2021](https://hashnode.com/posts/automate-boring-files-organizing-using-python-python-files-organizer/612d61a12858872661b9ed60/comment/6135acc292d0321a99995977#reply-613f74e1058ab733a84c40dd)

thank you so much for your feedback. i agree with you about turning this into a python class it will make the code more clean and remove the repeated/duplicate code. and specially the methods. thank you again for your comment
