Question: I was able to generate a list with my filenames:

```
allFiles =['https://myurl.com/something//something_01-01-2020.csv', 'https://myurl.com/something//something_01-02-2020.csv', 'https://myurl.com/something//something_01-03-2020.csv'...]

```

How could I find the filename with earliest date (within the file name) on this list and extract its date as variable?

Additional scenario: What if I have 00-00-0000.csv and 00-0000.csv on my list?

Answer: 
try this,

```
from datetime import datetime

min(allFiles,
    key=lambda x: datetime.strptime(x.split('_')[1].replace('.csv', ''), "%d-%m-%Y"))

```
Try this:

```
import re
from datetime import datetime

sorted(allFiles, key= lambda x: datetime.strptime(re.search("([0-9]{2}\-[0-9]{2}\-[0-9]{4})", x)[0], '%d-%m-%Y'))

```

it will sort your list based on date, so you can get what you want.

the first element is earliest.