命令行移动某些类型的所有文件,没有覆盖/ y不工作

问题描述 投票:0回答:1

cmd prompt命令有问题:

for /r E:\ %f in (*.jpg) do @move "%f" "E:\jpg" /Y

此命令行不按我预期的方式工作。我试图将我的外部驱动器上的某些类型(即jpg)上的所有文件移动到我的外部驱动器上的文件夹(E:/ jpg)

有什么建议???

1. (with /Y)

Microsoft Windows [Version 10.0.16299.125]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\█████>for /r E:\ %f in (*.jpg) do @move "%f" "E:\jpg" /Y
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.

2. (without /Y)

Microsoft Windows [Version 10.0.16299.125]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\█████>for /r E:\ %f in (*.jpg) do @move "%f" "E:\jpg"
Overwrite E:\jpg\10255420_10200945699085042_5035519864603771578_n.jpg? (Yes/No/All): Yes
        1 file(s) moved.
Overwrite E:\jpg\10307411_10201163984180409_2977646430196181302_n.jpg? (Yes/No/All): 
windows cmd
1个回答
0
投票

对于移动文件,您可以使用robocopy而不是move,默认情况下它不会覆盖目标文件,除非它们具有不同的大小或时间戳,并处理多个文件。

你应该可以使用它

robocopy %cd% "E:\jpg" *.jpg /MOV

注意:cd是当前目录的环境变量

https://ss64.com/nt/robocopy.html

© www.soinside.com 2019 - 2024. All rights reserved.