Ok, so there are a lot of files that I need to rename and they are all in the same directory. There are multiple folders in the directory with files in them than need to be renamed too.
What I need to do Is replace any space in the file name with an underscore.
I am a beginner at java, so I might be able to do this by myself if there was just one file and I could specify the file in Java, but in this situation I can't.
For example, if the file name is "file number one" I need to rename it to "file_number_one". I would also like to keep the extension unchanged. There are a bunch of files all with different extensions.
Thank you so much for the help and if there are any questions I will try to answer them to the best of my ability.
EDIT:
Ok, I figured it out, but not in Java. Using these websites here and here I figured it out using windown PowerShell.
Basically open up PowerShell, cd into the directory, and type:
dir -Recurse | Rename-Item –NewName { $_.name –replace “ “,”_” }
This replaces all spaces with an underscore in all files and folders in the directory. Sorry I could not figure it out in Java but this is an alternative that seems to work.