Use below code to give date from the file name into the file entry...
As you have not clearly mentioned how you want the output of your csv, You can just add what you want to add(just grep after sed).
for i in *.csv
do
Date_var=$(echo "$i" | awk -F "[_.]" '{ print $6,$7,$8 }' OFS="_" )
sed 's/server1.example.com/'$Date_var',server1.example.com/1'
done
If you are getting your desired output or need to add some specific data just add after the sed....
sed 's/server1.example.com/'$Date_var',server1.example.com/1' | grep "erver1.example.com" >> final_output.csv
The BEGIN block will be executed before reading the arguments. So, FILENAME will have null value (on many awk implementations including gawk).
The FS is not required.
FILENAME - The name of the current input file. If no files are specified on the command line,the value of FILENAME is "-". However, FILENAME is undefined inside the BEGIN block (unless set by getline).
so, iterating all the csv files, you can use for loop
for i in *.csv
do
nawk -F"[_.]" 'BEGIN{fdate=substr(FILENAME,length(FILENAME)-14,11)}NR==4{$0=fdate","$0;print}' $i
done