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"))

```
It seems that you want to extract the files based on the filename.

You can do:

```
min(allFiles, key=lambda x:x[-8:-4]+x[-11:-9]+x[-14:-12])

```

The `lambda` function here obtains a string such as `'20200101'` from the filename, by extracting the relevant parts and concatenating them in the correct order. Ordering by this string will produce date order.

This is based on the assumption that the filename adheres to a format of ending in `dd-mm-yyyy.csv`. If the dates were intended in fact to be `mm-dd-yyyy.csv` (not clearly specified in the question), then this would need to be changed to:

```
min(allFiles, key=lambda x:x[-8:-4]+x[-14:-12]x[-11:-9])

```