Python Forum

Full Version: Detecting file extensions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How do i make python listen for changes to a folder on my desktop, and every time a file was added, the program would read the file name and categorize it it based on the extension?

This is a part of a more detailed program but I don't know how to get started on this part. This part of the program detects when the user drags a file into a folder on his/her desktop and then moves that file to a different location based on the file extension
you can use package like watchdog to monitor your folder for changes, then using os.path.splitext() or pathlib's PurePath.siffix get the file extension and process the file accordingly