Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
List files without extension
I'm fairly new to python, and I am trying to write a script that will write all the files in a directory to a text file, but only write the files that have a certain extension (.avi, .rmvb, .mkv etc.) and only print the filename without the extension. So video.avi would become video in the text file, and text.txt would be ignored completely. So far I have been able to list the directory using os.listdir, and write it to a text file, but haven't been able to show only certain extensions and show only the filename. What would be the best way of doing this?
0 · ·