jpayne@68: package fileIO; jpayne@68: jpayne@68: import java.io.File; jpayne@68: jpayne@68: jpayne@68: public class CopyFiles { jpayne@68: jpayne@68: jpayne@68: public static void main(String[] args){ jpayne@68: for(String s : args){ jpayne@68: renameFiles(s); jpayne@68: } jpayne@68: } jpayne@68: jpayne@68: jpayne@68: public static void renameFiles(String path){ jpayne@68: File f=new File(path); jpayne@68: renameFiles(f); jpayne@68: } jpayne@68: jpayne@68: public static void renameFiles(File path){ jpayne@68: jpayne@68: if(path.isDirectory()){ jpayne@68: File[] array=path.listFiles(); jpayne@68: for(File f : array){renameFiles(f);} jpayne@68: }else{ jpayne@68: rename(path); jpayne@68: } jpayne@68: jpayne@68: } jpayne@68: jpayne@68: public static void rename(File in){ jpayne@68: assert(in.exists()); jpayne@68: assert(in.isFile()); jpayne@68: String abs=in.getAbsolutePath(); jpayne@68: jpayne@68: jpayne@68: int dot=abs.lastIndexOf('.'); jpayne@68: int slash=abs.lastIndexOf('/'); jpayne@68: jpayne@68: // String[] split=Person.parsePath(abs.substring(0, slash)); jpayne@68: // String name=split[0]; jpayne@68: // String out=abs.substring(0, dot)+"_"+name+".txt"; jpayne@68: jpayne@68: jpayne@68: jpayne@68: String fname=abs.substring(slash+1); jpayne@68: jpayne@68: // System.out.println(fname); jpayne@68: jpayne@68: jpayne@68: if(fname.startsWith("chr") && fname.endsWith(".txt")){ jpayne@68: jpayne@68: String out=abs.replace(".txt", ".flow"); jpayne@68: assert(!out.equals(abs)) : out+", "+abs; jpayne@68: jpayne@68: System.out.println("Renaming "+abs+" to "+out); jpayne@68: ReadWrite.copyFile(abs, out); jpayne@68: } jpayne@68: } jpayne@68: jpayne@68: }