github.com/qjfoidnh/BaiduPCS-Go@v0.0.0-20231011165705-caa18a3765f3/internal/pcscommand/rm_mkdir.go (about) 1 package pcscommand 2 3 import ( 4 "fmt" 5 "github.com/qjfoidnh/BaiduPCS-Go/pcstable" 6 "os" 7 "strconv" 8 ) 9 10 // RunRemove 执行 批量删除文件/目录 11 func RunRemove(paths ...string) { 12 paths, err := matchPathByShellPattern(paths...) 13 if err != nil { 14 fmt.Println(err) 15 return 16 } 17 18 pnt := func() { 19 tb := pcstable.NewTable(os.Stdout) 20 tb.SetHeader([]string{"#", "文件/目录"}) 21 for k := range paths { 22 tb.Append([]string{strconv.Itoa(k), paths[k]}) 23 } 24 tb.Render() 25 } 26 27 err = GetBaiduPCS().Remove(paths...) 28 if err != nil { 29 fmt.Println(err) 30 fmt.Println("操作失败, 以下文件/目录删除失败: ") 31 pnt() 32 return 33 } 34 35 fmt.Println("操作成功, 以下文件/目录已删除, 可在网盘文件回收站找回: ") 36 pnt() 37 } 38 39 // RunMkdir 执行 创建目录 40 func RunMkdir(path string) { 41 activeUser := GetActiveUser() 42 err := GetBaiduPCS().Mkdir(activeUser.PathJoin(path)) 43 if err != nil { 44 fmt.Printf("创建目录 %s 失败, %s\n", path, err) 45 return 46 } 47 48 fmt.Println("创建目录成功:", path) 49 }