Rename based on other filename that was just renamed

Hello all, newbie here and have been trying to read posts but haven't found anything on this specific issue I'm trying to do.
Will try to be concise.
There is a batch of auto-generated files that I'm trying to rename nightly.
-I have a content-matching PDF rule that I eventually got to work and rename a PDF into a format I like.
-not all files are PDF and don't have adequate content to match with. However the auto-generated filenames have portions of names that I can use to identify what report it is.
I want to take any of the remaining files that have NOT been renamed and follow the naming convention from the PDF I just managed to rename. These files would then get moved into a sub-folder or elsewhere on my own so the watch folder would be empty the next night.
Let me see if I can make an example:
ZZZZ reportname1- 7 D12 of 22.pdf (this is the one I am able to parse and rename)
ZZZZ diffreportname2-7 EP2 - D12 of 22.txt
ZZZZ diffreportname3 - 7 - D 12 - 22.txt
and I'm wanting to rename all of the files into:
ZZZZ reportname1 107 D12 of 22.pdf
ZZZZ diffreportname2 107 D12 of 22.txt
ZZZZ diffreportname3 107 D12 of 22.txt
Now... the problem comes when the diffreportname2 or diffreportname3 have variable spacing and stuff around them as they are generated. Yes I know the output generation should get fixed, but I can't do that.
The report names themselves always are there.
So my hope is to use the correct file-naming from the first PDF, then do a filename search for the just 'diffreportname2' for other files that dropped at the same time and then use all of the other information from the filename of the PDF I fixed to format these other reports correctly. These variables change nightly: ZZZZ, 107, D12, 22
This is why its a little funky.
I've been trying to look into bash scripting and things too.
Anyone have any ideas where to go look into this kind of renaming?
Thanks everyone
Will try to be concise.
There is a batch of auto-generated files that I'm trying to rename nightly.
-I have a content-matching PDF rule that I eventually got to work and rename a PDF into a format I like.
-not all files are PDF and don't have adequate content to match with. However the auto-generated filenames have portions of names that I can use to identify what report it is.
I want to take any of the remaining files that have NOT been renamed and follow the naming convention from the PDF I just managed to rename. These files would then get moved into a sub-folder or elsewhere on my own so the watch folder would be empty the next night.
Let me see if I can make an example:
ZZZZ reportname1- 7 D12 of 22.pdf (this is the one I am able to parse and rename)
ZZZZ diffreportname2-7 EP2 - D12 of 22.txt
ZZZZ diffreportname3 - 7 - D 12 - 22.txt
and I'm wanting to rename all of the files into:
ZZZZ reportname1 107 D12 of 22.pdf
ZZZZ diffreportname2 107 D12 of 22.txt
ZZZZ diffreportname3 107 D12 of 22.txt
Now... the problem comes when the diffreportname2 or diffreportname3 have variable spacing and stuff around them as they are generated. Yes I know the output generation should get fixed, but I can't do that.
The report names themselves always are there.
So my hope is to use the correct file-naming from the first PDF, then do a filename search for the just 'diffreportname2' for other files that dropped at the same time and then use all of the other information from the filename of the PDF I fixed to format these other reports correctly. These variables change nightly: ZZZZ, 107, D12, 22
This is why its a little funky.
I've been trying to look into bash scripting and things too.
Anyone have any ideas where to go look into this kind of renaming?
Thanks everyone