Rename page attachment

I started a page using xwiki 8.4.5 enterprise version in docker and pasted a lot of screendumps into that page. It turned out that all screendumps were named ‘image.png’, and only the last version is visible in the page.
Now I have upgraded to xwiki 9.11 as the paste image file name reuse is fixed. Now I need to fix the screendumps.
I can see from the filesystem that they are all available in the history as image.png/image~v1.1.png to image.png/image~1.30.png. How should I proceed to restore each revision back to a unique attachment png file which xwiki will accept? I don’t mind some manual work as this will probably never happen again in the future.

I guess if you found the actual files the annoying manual way is to copy them somewhere, rename them to what you want and then attachment them (you can upload several attachment at the same time).