Then here is a good example of filename error handling and implementing a formatted sequence number to force creation of a new valid name.
#!/bin/bash
filedir="${HOME}/testscripts/emptydir/"
filename="testfile"
fileext=".txt"
# format the date as year-month-date so it can be easily sorted
dt=$(date +"%y-%m-%d")
# loop through from 1 to 999
# adding each three digit number to the filename
# until a number that does not exist if found,
# then make the file with the available name
# use the seq command to increment a number, it is being formatted
# as a 3 digit number from 1 to 999
for seqnum in $(seq -f "%03g" 1 999)
do
# set a filename including the directory, base name,
# date, sequence number and the extension
fullfile="${filedir}${filename}-${dt}-${seqnum}${fileext}"
# test the see if the file exist, first test to see
# if it does not exist
#
# the ! means NOT
# the -f tests to see if the file exists
# so "! -f" means check to see if the file does not exist
#
if [ ! -f ${fullfile} ]
then
# since the file does not exist, make it
touch ${fullfile}
echo " ${fullfile} has been created"
# exit the loop since the file has been created
break
fi
done