I have 30 docx file with the different name in that I want to to replace the some letters without affecting the inside content how do I that?

Viewed 17

Like I am having Req_250: a Req_6497: b Sysreq_234 a Here I want to put-> "COLON" instead of ":" and "_" instead of " " How to that please give idea

1 Answers

You can used File renameTo() to rename your file

such as

File file=new File("../path/Req_250: a Req_6497: b Sysreq_234.docx");
boolean renameResult = file.renameTo(new File(file.getParent()+"/"+file.getName().replace(":", "COLON").replace(" ", "_")));
Related