-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoveBiliFile.java
More file actions
104 lines (95 loc) · 2.87 KB
/
Copy pathMoveBiliFile.java
File metadata and controls
104 lines (95 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import java.io.IOException;
import java.nio.file.*;
/**
* 合并手机b站下载文件
*/
public class MoveBiliFile {
/**
* 返回pathname目录下文件总数
* @param pathname
* @return
* @throws IOException
*/
public int CountCatalog(String pathname) throws IOException {
int count=0;
DirectoryStream<Path> paths = Files.newDirectoryStream(Paths.get(pathname));
for(Path path:paths ){
count++;
}
return count;
}
public int MoveFile(String pathname) {
int count=0;
String toprepath="E:/Music/res";
for(int i=1;i<421;i++){
String name=pathname+"/"+i+"/lua.mp4.bili2api.16/0.blv";
Path frompath = Paths.get(name);
String toname=toprepath+"/"+i+".mp4";
Path topath = Paths.get(toname);
try {
Files.move(frompath,topath,StandardCopyOption.ATOMIC_MOVE);
count++;
} catch (IOException e) {
e.printStackTrace();
}
}
return count;
}
public void diff(String pathname) {
int count=0;
DirectoryStream<Path> paths = null;
try {
paths = Files.newDirectoryStream(Paths.get(pathname));
for(Path path:paths ){
System.out.println(path);
}
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* gai
* @param tail
* @return
*/
public int changetail(String tail){
int count=0;
String toprepath="E:/Music/res";
for(int i=1;i<421;i++){
String name=toprepath+"/"+i+".txt";
Path frompath = Paths.get(name);
String toname=toprepath+"/"+i+tail;
Path topath = Paths.get(toname);
try {
Files.move(frompath,topath,StandardCopyOption.ATOMIC_MOVE);
count++;
} catch (IOException e) {
e.printStackTrace();
}
}
return count;
}
/**
* 修改后缀
* @param path 文件所在文件夹路径
* @param filename 文件名
* @param oldTail 后缀
* @param newTail 修改后的后缀
*/
public void changetail(String path,String filename,String oldTail,String newTail){
String name=path+"/"+filename+"."+oldTail;
Path frompath = Paths.get(name);
String toname=path+"/"+filename+"."+newTail;
Path topath = Paths.get(toname);
try {
Files.move(frompath,topath,StandardCopyOption.ATOMIC_MOVE);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
MoveBiliFile file=new MoveBiliFile();
int i = file.MoveFile("E:/Music/795213137");
System.out.println("成功移动数量为: "+i);
}
}