Java Simple method Bulk modify file name under Windows folder (Simple IO use)

Source: Internet
Author: User

 Packagetest.tttt;ImportJava.io.File;Importjava.util.ArrayList;Importjava.util.List; Public classFilerename { Public Static voidMain (string[] args) {File file=NewFile ("c:\\users\\issoh\\desktop\\みんなの Japanese 2nd edition Ⅱ");    ReName2 (file); }     Public Static voidreName2 (file file) {file[] files=File.listfiles (); List<String> sames =NewArraylist<>();  for(File f:files) {String fname=F.getname (); if(Fname.length () >10) {String same= Fname.substring (Fname.length ()-10, Fname.length ()); if(!Sames.contains (same))                {Sames.add (same); }Else{fname= Fname.replace ("1.mp3", "2.mp3");                } System.out.println (fname); F.renameto (NewFile ("c:\\users\\issoh\\desktop\\みんなの Japanese version 2nd ⅱ\\" +fname)); }        }    }     Public Static voidreName (file file) {file[] files=File.listfiles ();  for(File f:files) {String fname=F.getname (); if(Fname.length () >10) {System.out.println (fname); FName= Fname.replace ("rename 縺? 繧 Kusanagi ↑ 縺? symposium? 譛? Transformation Kuching? Pot 縲? 2 import medical?? 譛 shu Knots "," みんなの Japanese 2nd edition of the first Class Ⅱ "); FName= Fname.replace ("Random", "No."); if(Fname.contains ("縲 copy??")) ) {fname= Fname.replace ("Hidden 縲 copy??", "Meeting words"); }Else if(Fname.contains ("Hidden 縲???")) ) {fname= Fname.replace ("Hidden 縲 bat city??", "Question 1");                } System.out.println (fname); F.renameto (NewFile ("c:\\users\\issoh\\desktop\\みんなの Japanese version 2nd ⅱ\\" +fname)); }        }    }}

Java Simple method Bulk modify file name under Windows folder (Simple IO use)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.