Extract data before period in filename

Hi,
I have some files with these patterns:

WI_SCOPE_DATA_CHANGE_2017-09-12_15-30-40.txt
WI_SCOPE_BACK_COMPLETE_QUEUE_2017-09-12_15-31-40.txt
WI_SCOPE_CURRENT_CHECK_QUEUE_2017-09-12_15-32-40.txt
WI_SCOPE_DAILY_PARTY_2017-09-12_15-33-40.txt

I want to extract date from filename and save it in a variable. How can I extract date that is in position 2 of the filename before period?

Thread closed.

Please continue in your previous thread: