Having a folder with the following files
myoutput.pdf
hello.pdf.pdf
byebye.txt
hey.txt.txt
How can I remove the extension of ONLY the files with a duplicated extension? In the example there are only pdf and txt, but in the real example can be any type of extension.
I got this far:
String dir = "C:/Users/test";
File[] files = new File(dir).listFiles();
for (File file : files) {
if (file.isFile()) {
System.out.println(file.getName());
}
}
But I don't know how can I now detected the ones with "duplicated extension" and rename it to a "single extension"
My desired output would be:
myoutput.pdf
hello.pdf
byebye.txt
hey.txt
Thanks in advance.