package test0715;

import java.io.File;

public class FileRename {
public static void main(String[] args) {
File file=new File("f:/java/test");
String dirPath=file.getAbsolutePath();
System.out.println("dirPath: "+dirPath);
if(file.isDirectory()){
File[] files=file.listFiles();
long starttime=System.currentTimeMillis();
for(File fileFrom:files){
String fromFile=fileFrom.getName();
System.out.println("fromFile before: "+fromFile);
String toFileName;
int index;
index=fromFile.indexOf("p");
fromFile=fromFile.substring(index+1);
System.out.println("fromFile after: "+fromFile);

if(index!=-1){
toFileName=dirPath+"\\"+fromFile;
System.out.println("toFileName: "+toFileName);
File toFile=new File(toFileName);
if(fileFrom.exists()&&!toFile.exists()){
fileFrom.renameTo(toFile);
}
}
}
long endtime=System.currentTimeMillis();
System.out.println("Time:"+new Long(endtime-starttime));
}
}
}

批量修改文件名java的更多相关文章

  1. 使用Java中File类批量创建文件和批量修改文件名

    批量创建文件 int cont = 1; String s = "E:\\学习资料\\Java笔记-"; while(cont<100){ File f = new File ...

  2. Linux下find一次查找多个指定类型文件,指定文件或者排除某类文件,在 GREP 中匹配多个关键 批量修改文件名等

    http://blog.sina.com.cn/s/blog_62e7fe670101dg9d.html linux下二进制文件查找: strings 0000.ts | grep -o " ...

  3. [转载][记录]shell 批量修改文件名

    参考了:[新手入门] shell脚本批量修改文件名 4楼回复 我刚好是在vagrant+ubuntu中进行开发,windows手动修改太麻烦. #!/bin/ksh ls *.htm | while ...

  4. linux批量修改文件名的shell脚本

    linux中批量修改文件名的shell脚本代码,主要是使用了rename,结合shell,喜欢的朋友可以参考下 使用 rename 命令  ========================  NAME ...

  5. 用python批量修改文件名

    从youtube上当下来百来首mv,每个都需要去掉视频,这还挺好弄得,格式工厂一弄就完了,但是文件名,都带有乱七八糟的*啥的巴拉巴拉的,咋修改啊,几百首总不可能一个一个rename吧 #批量修改文件名 ...

  6. windows下如何批量修改文件名

    windows下如何批量修改文件名 一.总结 一句话总结:就是用excel生成了多条修改文件名的dos命令然后执行,比较核心的就是把图片名称导入excel 将图片名称导入excel---编写如下DOS ...

  7. C# 批量修改文件名

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  8. Linux下批量修改文件名(rename)

    原文地址: http://blog.csdn.net/sea_shore/article/details/6102437 1.rename命令批量修改文件名, 其实linux下可以使用别的办法来批量修 ...

  9. rename 批量修改文件名简单用法

    有的时候我们需要批量创建文件做测试,为了做区分,一般只要稍稍动动文件名即可,MV命令既可以移动文件,也是可以修改文件名的,但批量修改文件名MV做不到,此时,我们可以用rename命令批量修改是蛮不错的 ...

随机推荐

  1. 移动并改变alpha

    <script type="text/javascript">function obj(x){return document.getElementById(x);}va ...

  2. const和非const函数重载

    成员函数后面加const,表示在该函数中不能对类的数据成员进行改变,比如下面的代码: #include <stdio.h> class A { private: mutable int a ...

  3. leetcode Same Tree python

    # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = ...

  4. css3 transform 变形

    在css3中,用transform可以实现文字或图像的旋转.缩放.倾斜和移动,并且该元素下的所有子元素,随着父元素一样转.缩放.倾斜和移动. transform属性 transform的属性包括:ro ...

  5. flush privileges是什么意思?

    flush privileges 命令本质上的作用是将当前user和privilige表中的用户信息/权限设置从mysql库(MySQL数据库的内置库)中提取到内存里.MySQL用户数据和权限有修改后 ...

  6. php页面相互调用的知识点

    目前我们有这样一个需求: (1) a.php  页面要使用 b.php 定义的函数,我们可以使用 如下指令 require  require_once include   include_once 举 ...

  7. [原创]linux简单之美(二)

    原文链接:linux简单之美(二) 我们在前一章中看到了如何仅仅用syscall做一些简单的事,现在我们看能不能直接调用C标准库中的函数快速做一些"复杂"的事: section . ...

  8. C语言struct类型

    在实际问题中,一组数据往往具有不同的数据类型.例如, 在学生登记表中,姓名应为字符型:学号可为整型或字符型: 年龄应为整型:性别应为字符型:成绩可为整型或实型. 显然不能用一个数组来存放这一组数据. ...

  9. office软件卸载

    因为工具是微软出的,并且对应的是每一个版本,所以这里我给大家说下每个版本的对应卸载工具,和卸载方法. office2013卸载 下载对应卸载工具,安装工具,比如你的是2013版本的office,那么下 ...

  10. 转 批处理 %~dp0的意义

    http://nealcai.iteye.com/blog/1685192 http://blog.csdn.net/caz28/article/details/7448677 http://stac ...