You can use the "cut" command and work on the positions of the file name. That is good if you always have exactly the same length of the file names. Then you can use "awk" with '_' and '.' as field separators. And then you could use "sed" to strip away everything from the file name, leaving only the timestamp. For example, with sed it could be something like this:
Code:
sed -e 's/.*_\([0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}\).*/\1/'
Opening the file and reading from it can be done with "awk" where you count the lines and only start processing if the line counter is larger than 3 and then terminate if $0 is empty. Or you use "tail" with "-n +4" to start with the 4th line, combined with "head -n -3" to remove the last 3 lines. For step 4, you print the date (it is not a timestamp!) from step 1, following by the actual line being processed.
Or you implement this in a script language like Perl.