RadarURL
응용 프로그래밍

java 파일이름 변경하기

by JaeSoo posted Jun 24, 2007
?

Shortcut

PrevPrev Article

NextNext Article

ESCClose

Larger Font Smaller Font Up Down Go comment Print
import java.io.*;

class FileRename {
      public static void main(String[] args) {
            if (args.length != 1) {
                  System.out.println("Usage: java FileRename directory");
                  System.exit(0);
            }

            File dir = new File(args[0]);
            File[] list = dir.listFiles();

            for (int i = 0; i < list.length; i++) {
                  String fileName = list[i].getName();
                  // 파일명
                  String newFileName = "0000" + fileName;
                  newFileName = newFileName.substring(newFileName.length() - 7);
                  list[i].renameTo(new File(newFileName));
            }
      } // end of main

} // end of FileRename class

출처 : http://cafe.naver.com/marinebang.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=5354

Who's JaeSoo

profile

http://JaeSoo.com Administrator


Articles

1 2 3 4 5 6 7 8 9 10