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