Gautham Kanthasamy
Gautham Kanthasamy

Reputation: 229

Looping over files with same substring

I have a folder containing over 485 Zipped Files. The name of each file has uniform characters with a varying date. I need to do something for files that have the same date. How can I do so? Below is a slice of the file names I have:

Screenshot of the zipped files

I basically need to run a loop through the entire list of files with sub-loops on file numbers that have the same date. How can I do so?

Upvotes: 1

Views: 40

Answers (1)

Shai
Shai

Reputation: 114986

you can use glob:

import glob
for basefile in glob.glob('*.LOG'):
    for sub_names in glob.glob(basefile+'*'):
        # do your magic here

Upvotes: 1

Related Questions