-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrebaseline.go
51 lines (43 loc) · 1.33 KB
/
rebaseline.go
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
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
"strings"
"syscall"
)
var directory = flag.String("directory", "/", "directory of files to rebaseline")
func main() {
flag.Parse()
fmt.Println(*directory)
file_names, err := ioutil.ReadDir(*directory)
if err != nil {
fmt.Println(err)
syscall.Exit(1)
}
for i := 0; i < len(file_names); i++ {
file_name := file_names[i].Name()
if !strings.Contains(file_name, ".good.") {
continue
}
// If string contains ".good.", delete the version of the file that doesn't and rename.
// For PartNetwork__Part_7-511A21310-011~8V613__Container_Scrape__Expected_Results.good.xlsx
// delete PartNetwork__Part_7-511A21310-011~8V613__Container_Scrape__Expected_Results.xlsx
// and rename PartNetwork__Part_7-511A21310-011~8V613__Container_Scrape__Expected_Results.good.xlsx
// to PartNetwork__Part_7-511A21310-011~8V613__Container_Scrape__Expected_Results.xlsx
original_file_name := strings.Replace(file_name, ".good.", ".", -1)
fmt.Println("Removing: " + original_file_name)
err = os.Remove(*directory + original_file_name)
if err != nil {
fmt.Println(err)
syscall.Exit(1)
}
fmt.Println("Renaming: " + file_name + " to: " + original_file_name)
os.Rename(*directory+file_name, *directory+original_file_name)
if err != nil {
fmt.Println(err)
syscall.Exit(1)
}
}
}