Mercurial > repos > rliterman > csp2
comparison 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 |
comparison
equal
deleted
inserted
replaced
67:0e9998148a16 | 68:5028fdace37b |
---|---|
1 package fileIO; | |
2 | |
3 import java.io.File; | |
4 | |
5 | |
6 public class CopyFiles { | |
7 | |
8 | |
9 public static void main(String[] args){ | |
10 for(String s : args){ | |
11 renameFiles(s); | |
12 } | |
13 } | |
14 | |
15 | |
16 public static void renameFiles(String path){ | |
17 File f=new File(path); | |
18 renameFiles(f); | |
19 } | |
20 | |
21 public static void renameFiles(File path){ | |
22 | |
23 if(path.isDirectory()){ | |
24 File[] array=path.listFiles(); | |
25 for(File f : array){renameFiles(f);} | |
26 }else{ | |
27 rename(path); | |
28 } | |
29 | |
30 } | |
31 | |
32 public static void rename(File in){ | |
33 assert(in.exists()); | |
34 assert(in.isFile()); | |
35 String abs=in.getAbsolutePath(); | |
36 | |
37 | |
38 int dot=abs.lastIndexOf('.'); | |
39 int slash=abs.lastIndexOf('/'); | |
40 | |
41 // String[] split=Person.parsePath(abs.substring(0, slash)); | |
42 // String name=split[0]; | |
43 // String out=abs.substring(0, dot)+"_"+name+".txt"; | |
44 | |
45 | |
46 | |
47 String fname=abs.substring(slash+1); | |
48 | |
49 // System.out.println(fname); | |
50 | |
51 | |
52 if(fname.startsWith("chr") && fname.endsWith(".txt")){ | |
53 | |
54 String out=abs.replace(".txt", ".flow"); | |
55 assert(!out.equals(abs)) : out+", "+abs; | |
56 | |
57 System.out.println("Renaming "+abs+" to "+out); | |
58 ReadWrite.copyFile(abs, out); | |
59 } | |
60 } | |
61 | |
62 } |