(May-05-2021, 05:07 PM)tester_V Wrote: I see why the snippets not working. They all looking for a filename "latest" but I'm not looking for the 'latest' file name.
I'm looking for a string with the word 'latest' in the files in the directory...
I'd like to use 'any()' to tell if the file has or has not the word.
Sorry for the confusion!
Then for each file, you'll need to
open()
the file, read()
the data and compare that data to your target. If you get a match, store the filename or just print it out and move on to the next file.
ETA:
And using any() to find the match in the file would be reasonable. Something like...
with open(filename, "r") as f: if any(tofind in line for line in f): print(f"Filename {filename} matched")