[英]Move files in specific subfolders to another subfolder
I have folder C:\\Folder
.我有文件夹C:\\Folder
。 In this folder I have thousands of subfolders.在这个文件夹中,我有数千个子文件夹。 I want to target only those ending in cv
.我只想针对那些以cv
结尾的人。 In these subfolders I have a file and another subfolder.在这些子文件夹中,我有一个文件和另一个子文件夹。 C:\\Folder\\SubFoldercv\\cv
. C:\\Folder\\SubFoldercv\\cv
。 I would like to move all the files in those subfolders to the second subfolder using CMD in Windows 10.我想在 Windows 10 中使用 CMD 将这些子文件夹中的所有文件移动到第二个子文件夹。
(So from C:\\Folder\\SubFoldercv
to C:\\Folder\\SubFoldercv\\cv
). (所以从C:\\Folder\\SubFoldercv
到C:\\Folder\\SubFoldercv\\cv
)。
Use for /D
to find the directories ending with cv
, and use robocopy
to copy (or robocopy /mov
to move) all files from a folder to another:使用for /D
查找以cv
结尾的目录,并使用robocopy
将所有文件从一个文件夹复制(或robocopy /mov
移动)到另一个文件夹:
@echo off
FOR /D %%G IN ("C:\Folder\*cv") DO robocopy /mov "%%~G" "%%~G\cv" "*"
I'm currently not on a windows machine so I'm not able to test it but it should do the trick and move all files to the cv
subfolder for all folders ending on cv
.我目前不在 Windows 机器上,所以我无法对其进行测试,但它应该可以解决问题,并将所有文件移动到cv
子文件夹中以cv
结尾的所有文件夹。
If you want to use it on the command-line, use:如果要在命令行上使用它,请使用:
FOR /D %G IN ("*cv") DO robocopy /mov "%~G" "%~G\cv" "*"
instead.反而。
EDIT : After the OP tested it, he has confirmed that it works.编辑:在 OP 对其进行测试后,他已确认它有效。
How to do?怎么做?
subfolderHolder = uploads
FOR /D %%i IN ("%MoveDirSource%\*\%subfolderHolder%\*") DO ROBOCOPY /MOV /E "%%i" "%MoveDirDestination%\%%~nxi"
but the wild card is not working但通配符不起作用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.