Your short data string
may not be returning with delimiters, like a hyphen.
What do you get when you run…
short date string of (current date)
Your short data string
may not be returning with delimiters, like a hyphen.
What do you get when you run…
short date string of (current date)
I get
20210804
so no delimiters at all.
EDIT 1
And now having tested it in Script Debugger I can see that I didn’t need to do all that reformatting of the date in script. I still need to use the Script for renaming the file to get the custom metadata date into YYYYMMDD form but its much simpler to do with my date settings as it formats the date in the way I want it without any manipulation. Well I have learnt a few things about scripting doing it this way.
EDIT 2
And now the script is working exactly as I need it to. It’s much simpler and it can leave the account number out if there isn’t one. Great stuff.
The date formats, including short date, are defined in System Preferences > Language & Region > Dates…
Glad you have you script working and you learned new things. Even more glad to hear the enjoyment and sense of accomplishment in your post.