From 957ecb0ec409c02e5d48c2eaa94b72352fcb3894 Mon Sep 17 00:00:00 2001 From: VIVIMAN Date: Tue, 28 Feb 2023 19:45:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20hzb=20=E8=BD=AC=20zip=20?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...下文件夹,文件向上移动两层.go | 43 ++++++++++++++++++ ...下文件夹,文件向上移动两层.go | 45 +++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 golang_learn/data_func/go_to_dir/readDir/linux读取指定目录下文件夹,文件向上移动两层.go create mode 100644 golang_learn/data_func/go_to_dir/readDir/windows读取指定目录下文件夹,文件向上移动两层.go diff --git a/golang_learn/data_func/go_to_dir/readDir/linux读取指定目录下文件夹,文件向上移动两层.go b/golang_learn/data_func/go_to_dir/readDir/linux读取指定目录下文件夹,文件向上移动两层.go new file mode 100644 index 0000000..d9adfbf --- /dev/null +++ b/golang_learn/data_func/go_to_dir/readDir/linux读取指定目录下文件夹,文件向上移动两层.go @@ -0,0 +1,43 @@ +package main + +import ( + "fmt" + "os/exec" + "path/filepath" +) + +func main() { + a, _ := filepath.Abs("./") + fmt.Printf("当前目录:%s\n", a) + + // 执行解压操作,固定死目录和文件名称 + // drc:drc jth:jth 同目录下存在 unzip 目录(用于解压文件) + shellUnzip := fmt.Sprintf("cd %s && "+ + "export Hy7zEncryptPath=%s/drc.drc && "+ + "export Hy7zJarPath=%s/jth.jth && "+ + "export Hy7zLogFileName=%s/hy_7z.log && "+ + "/opt/apps/cn.com.epsoft.qggwy/files/qggwy/jdk/bin/java -jar -Xms512m -XX:MetaspaceSize=256M -XX:MaxMetaspaceSize=512M "+ + "%s/jth.jth unzip %s/1.hzb %s/unzip %s/unzip/Photos Z93z4H5b6z7d35b8", a, a, a, a, a, a, a, a) + cmd := exec.Command(shellUnzip) + _ = cmd.Run() + + mvPhotos, all := fmt.Sprintf("cd %s/unzip/Photos", a), "" + cmd = exec.Command(mvPhotos) + _ = cmd.Run() + for _, i := range f { + for _, i2 := range f { + all += fmt.Sprintf("cd %s/%s/ && mv * ../ && ", i, i2) + } + all += fmt.Sprintf("cd %s/ && mv * ../ && ", i) + } + all += "ls" + cmd = exec.Command(all) + _ = cmd.Run() + + // 生成压缩包 + zipFile := fmt.Sprintf("7z a 1.zip %s/unzip/", a) + cmd = exec.Command(zipFile) + _ = cmd.Run() +} + +var f = []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"} diff --git a/golang_learn/data_func/go_to_dir/readDir/windows读取指定目录下文件夹,文件向上移动两层.go b/golang_learn/data_func/go_to_dir/readDir/windows读取指定目录下文件夹,文件向上移动两层.go new file mode 100644 index 0000000..6dd8d2c --- /dev/null +++ b/golang_learn/data_func/go_to_dir/readDir/windows读取指定目录下文件夹,文件向上移动两层.go @@ -0,0 +1,45 @@ +package main + +import ( + "fmt" + "os/exec" + "path/filepath" +) + +func main() { + a, _ := filepath.Abs("./") + fmt.Printf("当前目录:%s\n", a) + + a = "E:/" + + cmd := exec.Command("del /S/Q unzip\\*.*") + _ = cmd.Run() + + // 执行解压操作,固定死目录和文件名称 + // drc:drc jth:jth 同目录下存在 unzip 目录(用于解压文件) + shellUnzip := fmt.Sprintf("cd %s && "+ + "set Hy7zEncryptPath=%s/drc.drc && "+ + "set Hy7zJarPath=%s/jth.jth && "+ + "set Hy7zLogFileName=%s/hy_7z.log && "+ + "D:\\hzb2022\\tomcat8\\JDK1.8\\jre\\bin\\java -jar -Xms512m -XX:MetaspaceSize=256M -XX:MaxMetaspaceSize=512M "+ + "%s/jth.jth unzip %s/1.hzb %s/unzip %s/unzip/Photos Z93z4H5b6z7d35b8", a, a, a, a, a, a, a, a) + cmd = exec.Command(shellUnzip) + _ = cmd.Run() + + mvPhotos, all := fmt.Sprintf("%s/unzip/Photos", a), "" + for _, i := range e { + for _, i2 := range e { + all += fmt.Sprintf("move %s/%s/%s/*.* %s && ", mvPhotos, i, i2, mvPhotos) + } + } + all += "ls" + cmd = exec.Command(all) + _ = cmd.Run() + + // 生成压缩包 + zipFile := fmt.Sprintf("7z a 1.zip %s/unzip/", a) + cmd = exec.Command(zipFile) + _ = cmd.Run() +} + +var e = []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"}