Here's the scenario:
I have a long list of time-stamped file names with characters before and after the time-stamp.
Something like this: prefix_20160817_suffix
What I want is a list (which will ultimately be a subset of the original list) that contains file names with specific prefixes, suffixes, and parts of the timestamp. These specific strings are already given in a list. Note: this "contains" list might vary in size.
For example: ['prefix1', '2016', 'suffix'] or ['201608', 'suffix']
How can I easily get a list of file names that contain every element in the "contains" array?
Here's some pseudo code to demonstrate what I want:
for each fileName in the master list:
if the fileName contains EVERY element in the "contains" array:
add fileName to filtered list of filenames
filtered_list = [fn for fn in master_list if all(item in fn for item in contains_list)]all(element in fileName for element in contains)?