Python Forum
Detecting file extensions - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Detecting file extensions (/thread-14105.html)



Detecting file extensions - ellipsis - Nov-15-2018

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


RE: Detecting file extensions - buran - Nov-15-2018

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