- Let's look at a Python script that will place all of your files in the appropriate folder.
- This script will first list all of the files and place them in folders based on their extensions, such as ".pdf" which will be placed in the PDFs folder, and so on for all of the files.
- Finally, all of the files will be placed in their proper directories.
- Import OS module
- Using the chdir function, change the location where the files will be imported.
- List all of the files using the listdir function, and then delete any files that don't have an extension like any folder.
- Run a loop for all of the files, putting them in the appropriate folders based on their extensions.
- Finally, each file will be placed in its own folder.