Retrieve/Increment a field value before saving swriter document

Dear Sir,
I’ve this folder/directory with documents####.ods that are suposed to be saved with a compuond name with 4 letter em 4 number ex: ACRA####/YYYY.
As far as i realize, Before Saving, i must gather all files from the folder “Descending” in order to get/read the last one as texttonumber +1 and cancatenate ‘ACRA’+last.number+1+’/’+Date?
How can this be done, if possible?

.ods files are spreadsheets. Consequently tag should be calc instead of writer.
Renaming files is better done with OS utilities. There are tons of them. Unfortunately you didn’t mention your OS. I can give you tricks under Linux.