Bash script to create directories and files with a numbered prefix
tail must to read the whole file. Calling sort with a -r (aka --reverse option) you can use head instead.
touch takes multiple arguments. You may

touch $DIRNAME/first.txt $DIRNAME/second.txt $DIRNAME/third.json


and further use brace expansion:

touch $DIRNAME/{first.txt,second.txt,third.json}

I would consider here-documenting the json files instead of echoing them, along the lines of:

cat &lt;&lt; EOF &gt;&gt; $DIRNAME/test.json
{
     "enabled": true
}
EOF