I’m running a script that runs through folders and files and use these very simple loops. Now I was wondering how I could compare the current filename with the one that comes next, within this loop?
list_of_files = {}
for (dirpath, dirnames, filenames) in os.walk(path):
for filename in filenames:
print 'I know here I could print: ', filename
print 'but how could I print: ', filename+1
Generally, what I want to accomplish is to compare the two files, select one on certain criteria, compare with the next in the same folder on these criteria – until the end of the folder. In the next folder I would like to do the same again.
You may be able to extend this to do what you want:
like this:
Edit: I forgot about itertools.