java 批量重命名工具类

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jiepu.downloader.example;

import java.io.File;


/**
 *
 * @author 批量重命名
 */
public class ReName {
    
    public static  void main(String args[])
    {
        String directory="D:\\Downloader\\4shared-api\\Downloader\\src\\images\\ProgressBar\\";
        String prefix="ProgressBar_";
        String suffix;
        File file=new File(directory);
        File[] files=file.listFiles();
        for(int i=0;i<files.length;i++)
        {
            File data=files[i];
            suffix=data.getAbsolutePath().substring(data.getAbsolutePath().lastIndexOf("."));
            System.out.println(suffix);
            File dest=new File(directory+prefix+i+suffix);
            boolean flag=files[i].renameTo(dest);
            System.out.println(flag);
        }
        
        
    }
    
}

你可能感兴趣的:(java 批量重命名工具类)