Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save discarn8/8fd1bbbc0d1f3cfbc0465157c69bb7e2 to your computer and use it in GitHub Desktop.

Select an option

Save discarn8/8fd1bbbc0d1f3cfbc0465157c69bb7e2 to your computer and use it in GitHub Desktop.
Python_list_specific_filetypes_in_directory
import os
#Change csv to match the file extension you are searching for
path = "C:/path/to/files/*.csv"
for fname in glob.glob(path):
temp1=os.path.basename(os.path.normpath(fname))
filename=temp1.split('.')[0]
print(filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment