-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencoding_script.java
More file actions
71 lines (60 loc) · 2.33 KB
/
encoding_script.java
File metadata and controls
71 lines (60 loc) · 2.33 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
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
String[] images = {"plane", "culturalcentre", "randomimage", "wintertrees", "autumntrees", "sunset", "poolballs", "umbrella", "nightshot", "gradient", "lipsum", "dragon", "face", "rays", "ducks"};
String[] infixes = {"libjpeg-turbo", "mozjpeg", "jpegoptim", "jpeg-recompress"};
for (String infx : infixes){
for (String o : images){
String infix = infx;
String image = o;
String path = "H:\\EE\\Images\\TO USE\\";
String disk = "H:";
// code adapted https://stackoverflow.com/questions/15464111/run-cmd-commands-through-java
ProcessBuilder builder = new ProcessBuilder(
"cmd.exe", "/c", disk + " && cd \"" + path + "\" && SCRIPT1 " + infix + " " + image);
builder.redirectErrorStream(true);
Process p = builder.start();
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while (true) {
line = r.readLine();
if (line == null) { break; }
System.out.println(line);
}
String inpath = new String(path + image + "_" + infix + ".log");
String outpath = new String(path + image + "_" + infix + "_CLEAN" + ".csv");
File inputFilepath = new File(inpath);
File outputFilepath = new File(outpath);
Scanner input = new Scanner(inputFilepath);
PrintWriter writer = new PrintWriter(outputFilepath);
String writerString = "";
while (input.hasNextLine()) {
String temp = input.nextLine();
if (temp.contains("Execution time: ")) {
String[] tempSplit = temp.split(" ");
writerString += "," + tempSplit[2];
}
else if (temp.contains("datatoken#")) {
String[] tempSplit = temp.split("#");
writerString = tempSplit[1] + writerString;
writer.println(writerString);
writerString = "";
}
}
System.out.println("done");
String nppPath = "H:\\Program Files\\Notepad++\\notepad++.exe";
ProcessBuilder nppout = new ProcessBuilder("\"" + nppPath + "\" \"" + outpath + "\"");
nppout.redirectErrorStream(true);
nppout.start();
input.close();
writer.close();
System.out.println(o + " done");
}
}
}
}