mercredi 7 novembre 2018

Finding file name in txt file with file names in it

I would like to find certain file names in a txt file with names of files in it. Below is what I have right now. I load the file called "newcatalog" and read and search the lines in it. Then, I go through the lines in "newcatalog" and try and find the file names that are from a folder. It doesn't print the lines with the found file names at the end.

newcatalog = open(dir+'newS34catalog.txt', "r")
searchlinesnew = newcatalog.readlines()
newcatalog.close()

for i,line in enumerate(searchlinesnew):
   for file in folder1:
       if file in line:
          print(line)

Aucun commentaire:

Enregistrer un commentaire