'Rename files in reverse numerical order

Someone sent me an photo archive that had all of its files in reverse numerical order. Tried asking the company for a properly numbered archive, but no dice. Normally I would manually rename each file, but there are 200+ files and that's too much effort.

So I thought of writing a script to read the files in the archive and rename them; but I actually haven't coded in 3 years, and quickly realized that I had no idea what to write, much less how to turn it into a usable script.

Most I could come up with was this extremely basic poorly-written pseudocode. Any help would be appreciated.

 scanner s = input file directory somehow
 int j = # of files;
    for(int i = 0; j < i; i++){
    
    s=read file
    filename = j-i.jpg
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source