Last active
August 29, 2015 14:28
-
-
Save kirkbyo/55d88fbca3d678ca8307 to your computer and use it in GitHub Desktop.
Writes all files that end with a certain extentsion to a .txt file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
# Writes all files that end with a certain extentsion to a .txt file | |
# Works in both Python 2 and Python 3 | |
extension = ".png" | |
fileList = os.listdir('Outflow-Icons') | |
for fichier in fileList[:]: # filelist[:] makes a copy of filelist. | |
if not(fichier.endswith(extension)): | |
fileList.remove(fichier) | |
textFile = open("output.txt", "w") | |
for item in fileList: | |
textFile.write('"{}",\n'.format(item)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment