How to insert filename by changing format to same file?

I have many files. File format is year(4-digit)month(2-digit)day(2-digit) Sample filenames: 20150101.txt 20150102.txt Content of sample filenames 00:00:13 -> 001528 I want to extract data as date from filename and then to insert it in the file Desired output 2015-01-01T00:00:13 001528 or 2015-01-01 00:00:13 001528 I tried one of below code for files in *txt; do…

Details