mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-01-23 14:32:14 +08:00
add skip confirm flag for rename command
This commit is contained in:
parent
5b22c4400a
commit
e0e8bc3284
@ -77,6 +77,9 @@ func CmdRename() cli.Command {
|
||||
|
||||
4. 批量重命名,将当前目录下所有.mp4文件全部进行 "视频+编号.mp4" 的重命名操作,旧的名称全部去掉,即:视频001.mp4, 视频002.mp4, 视频003.mp4...
|
||||
aliyunpan rename * 视频###.mp4 *.mp4
|
||||
|
||||
5. 批量重命名,将当前目录下所有.mp4文件全部进行 "视频+编号.mp4" 的重命名操作,旧的名称全部去掉,直接重命名无需人工确认操作
|
||||
aliyunpan rename -y * 视频###.mp4 *.mp4
|
||||
`,
|
||||
Category: "阿里云盘",
|
||||
Before: ReloadConfigFunc,
|
||||
@ -93,7 +96,7 @@ func CmdRename() cli.Command {
|
||||
RunRename(parseDriveId(c), c.Args().Get(0), c.Args().Get(1))
|
||||
} else if c.NArg() == 3 {
|
||||
// 批量重命名
|
||||
RunRenameBatch(parseDriveId(c), c.Args().Get(0), c.Args().Get(1), c.Args().Get(2))
|
||||
RunRenameBatch(c.Bool("y"), parseDriveId(c), c.Args().Get(0), c.Args().Get(1), c.Args().Get(2))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
@ -103,6 +106,10 @@ func CmdRename() cli.Command {
|
||||
Usage: "网盘ID",
|
||||
Value: "",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "y",
|
||||
Usage: "跳过人工确认,对批量操作有效",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -150,7 +157,7 @@ func RunRename(driveId string, oldName string, newName string) {
|
||||
}
|
||||
|
||||
// RunRenameBatch 批量重命名文件
|
||||
func RunRenameBatch(driveId string, expression, replacement, filePattern string) {
|
||||
func RunRenameBatch(skipConfirm bool, driveId string, expression, replacement, filePattern string) {
|
||||
if len(expression) == 0 {
|
||||
fmt.Println("旧文件名不能为空")
|
||||
return
|
||||
@ -209,6 +216,7 @@ func RunRenameBatch(driveId string, expression, replacement, filePattern string)
|
||||
}
|
||||
|
||||
// 确认
|
||||
if !skipConfirm {
|
||||
fmt.Printf("以下文件将进行对应的重命名\n\n")
|
||||
idx := 1
|
||||
for _, file := range files {
|
||||
@ -222,6 +230,7 @@ func RunRenameBatch(driveId string, expression, replacement, filePattern string)
|
||||
fmt.Println("用户取消了操作")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 重命名
|
||||
for _, file := range files {
|
||||
|
Loading…
Reference in New Issue
Block a user