Added a check for whether or not the directory is empty.
Separated the file renaming code from the rest of the code for clarity.
Fixed a small error and added a println message at the end of the program to separate output if one were to run the program many times in a single terminal.