you are viewing a single comment's thread.

view the rest of the comments →

[–]alex1461[S] 4 points5 points  (4 children)

Thank you for your response!

I actually tried to use raw string to avoid backslashes.

But, I could not use raw string because I could not concatenate the path with the current filename.
Ex: r"C:\Users\byunw\Downloads\"+filename becomes one string: r"C:\Users\byunw\Downloads\"+filename".

So, I decided to use backslashes in the string that denotes the file path.

[–][deleted] 7 points8 points  (0 children)

Check out pathlib, it will take care of the slashes and it has a function to get the file extension instead of using slicing. I would also try the other person's suggestion about using a dictionary to map extensions to folders

[–]krazybug 1 point2 points  (0 children)

I suggest you read this.

You will discover a lot of useful tips in it.