annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/opt/bbmap-39.01-1/current/fileIO/CopyFiles.java @ 68:5028fdace37b

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 16:23:26 -0400
parents
children
rev   line source
jpayne@68 1 package fileIO;
jpayne@68 2
jpayne@68 3 import java.io.File;
jpayne@68 4
jpayne@68 5
jpayne@68 6 public class CopyFiles {
jpayne@68 7
jpayne@68 8
jpayne@68 9 public static void main(String[] args){
jpayne@68 10 for(String s : args){
jpayne@68 11 renameFiles(s);
jpayne@68 12 }
jpayne@68 13 }
jpayne@68 14
jpayne@68 15
jpayne@68 16 public static void renameFiles(String path){
jpayne@68 17 File f=new File(path);
jpayne@68 18 renameFiles(f);
jpayne@68 19 }
jpayne@68 20
jpayne@68 21 public static void renameFiles(File path){
jpayne@68 22
jpayne@68 23 if(path.isDirectory()){
jpayne@68 24 File[] array=path.listFiles();
jpayne@68 25 for(File f : array){renameFiles(f);}
jpayne@68 26 }else{
jpayne@68 27 rename(path);
jpayne@68 28 }
jpayne@68 29
jpayne@68 30 }
jpayne@68 31
jpayne@68 32 public static void rename(File in){
jpayne@68 33 assert(in.exists());
jpayne@68 34 assert(in.isFile());
jpayne@68 35 String abs=in.getAbsolutePath();
jpayne@68 36
jpayne@68 37
jpayne@68 38 int dot=abs.lastIndexOf('.');
jpayne@68 39 int slash=abs.lastIndexOf('/');
jpayne@68 40
jpayne@68 41 // String[] split=Person.parsePath(abs.substring(0, slash));
jpayne@68 42 // String name=split[0];
jpayne@68 43 // String out=abs.substring(0, dot)+"_"+name+".txt";
jpayne@68 44
jpayne@68 45
jpayne@68 46
jpayne@68 47 String fname=abs.substring(slash+1);
jpayne@68 48
jpayne@68 49 // System.out.println(fname);
jpayne@68 50
jpayne@68 51
jpayne@68 52 if(fname.startsWith("chr") && fname.endsWith(".txt")){
jpayne@68 53
jpayne@68 54 String out=abs.replace(".txt", ".flow");
jpayne@68 55 assert(!out.equals(abs)) : out+", "+abs;
jpayne@68 56
jpayne@68 57 System.out.println("Renaming "+abs+" to "+out);
jpayne@68 58 ReadWrite.copyFile(abs, out);
jpayne@68 59 }
jpayne@68 60 }
jpayne@68 61
jpayne@68 62 }