zoukankan      html  css  js  c++  java
  • java 批量文件后缀重命名


    import
    java.io.File; public class BatchFileSuffixRename { public static void main(String[] args) { // TODO Auto-generated method stub // File.separator  这是用你所用的系统默认的文件分割符 // String path = "C:"+File.separator+"my.doc" ; String path = "E:" + File.separator + "cc" + File.separator + "images" + File.separator + "Images"; //String path = "E:\cc\images\Images"; // String path = "E:/cc/images/Images"; String from = "JPG"; String to = "jpg"; suffixRename(path, from, to); } /** * * @param path 要批量修改后缀名文件夹路径 * @param from 源文件后缀名 * @param to 修改后目标文件后缀名 */ public static void suffixRename(String path, String from, String to) { File file = new File(path); File[] fs = file.listFiles(); for (int i = 0; i < fs.length; i++) { File f2 = fs[i]; if (f2.isDirectory()) { suffixRename(f2.getPath(), from, to); } else { String name = f2.getName(); if (name.endsWith(from)) { f2.renameTo(new File(f2.getParent() + File.separator + name.substring(0, name.indexOf(from)) + to)); } } } } }
  • 相关阅读:
    paramiko连接并配置交换机
    Paramiko-sftp上传和下载文件
    常做的性能测试包含哪些?
    术语?
    什么是【负载测试】和【压力测试】?
    什么是性能?
    web服务器
    兼容性测试?
    可用性测试?
    什么是【回归测试】?
  • 原文地址:https://www.cnblogs.com/bluestorm/p/3694670.html
Copyright © 2011-2022 走看看