It is not clear why you need a nested loop or whether you need to iterate over a range of dates or not. But the script will look like this:
#!/bin/bash
DAY_FROM=1 # This is a first (starting) day
DAY_TO=24 # This is the last day
DATE=$(date +%Y%m%d) # This is a date we are processing.
id=0 # This is a number for our unique ID generation.
# It is being incremented for each day.
# Since this variable is in global scope,
# it will be unique no matter how many dates you process.
# If you want unique ID be unique only for date scope,
# reset it to 0 before processing each date.
# Let's go iterate over all days.
for (( i=$DAY_FROM; i <= $DAY_TO; ++i ))
do
let ++id # Increment our unique ID number...
# Print filename, date, number and unique ID.
# %04d at the end means that we output an integer
# with 4 digits padded with zeroes if needed.
printf "%s %s %s %04d\n" "filename$i" "$DATE" "$i" "$id"
done
... and the output will be like this:
filename1 20101007 1 0001
filename2 20101007 2 0002
filename3 20101007 3 0003
....
Hope it helps!