Import java. Io. *; <br/>/** <br/> * programs implemented by Java to change the file Suffix in batches. <Br/> * @ author laozizhu.com) <br/> */<br/> public class extbatchrename {<br/>/** <br/> * modify the program. <Br> <br/> * internal recursive call, rename the subdirectory <br/> * @ Param path <br/> * @ Param from <br/> * Original suffix name, including (. click) <br/> * @ Param to <br/> * The suffix of the name, which also includes (. point) <br/> */<br/> Public void Rename (string path, string from, string to) {<br/> file F = new file (PATH ); <br/> file [] FS = f. listfiles (); <br/> for (INT I = 0; I <FS. length; ++ I) {<br/> file F2 = FS [I]; <br/> If (f2.isdirectory () {<br/> Rename (f2.getpath (), from, to); <br/>}else {<br/> string name = f2.getname (); <br/> If (name. endswith (from) {<br/> f2.renameto (new file (f2.getparent () + "/" + name. substring (0, name. indexof (from) + )); <br/>}< br/> Public static void main (string [] ARGs) {<br/> extbatchrename Rf = new extbatchrename (); <br/> RF. rename ("D:/www.laozizhu.com ",". JSP ",". html "); <br/>}< br/>}
Recursive call is the key code and sub-directories can be modified.