Java Rename File renameFiles(File fileDirectory, String regex, String replacement)

Here you can find the source of renameFiles(File fileDirectory, String regex, String replacement)

Description

rename Files

License

Open Source License

Declaration

public static void renameFiles(File fileDirectory, String regex, String replacement) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    public static void renameFiles(File fileDirectory, String regex, String replacement) {
        for (File file : fileDirectory.listFiles()) {
            File newFile = new File(file.getAbsolutePath().replaceFirst(regex, replacement));
            file.renameTo(newFile);//from   w  ww . ja  v  a  2 s  .c om
        }
    }
}

Related

  1. renameFile(String src_pathname, String dest_pathname)
  2. renameFileFromChinese(File file)
  3. renameFileHard(File srcFile, File destFile)
  4. renameFileIfExists(File f)
  5. renameFileOnWindows(File oldFile, File newFile)
  6. renameFiles(String rootDir, String sourcePostfix, String destPostfix)
  7. renameFolder(String destinationFolderPath, String zipFileName, String prefix)
  8. renameLocal(String oldPath, String newPath)
  9. renameOldFile(final String fileName)