首页 > 解决方案 > 使用命令行移动特定名称的所有文件

问题描述

我要做的是使用命令行将仅具有特定名称的文件夹从子目录移动到新位置(例如 from C:\users\me\desktop\animalsto )。C:\users\me\desktop\folder2例如:

本质上,假设我有一个 Animals 文件夹,其中包含三个子文件夹:BirdsMammalsReptiles如下:

Animals
  Birds
    Breathe
      more subdirectories
    Feathers
      more subdirectories
  Mammals
    Fur
      more subdirectories
    Breathe
      more subdirectories
  Reptiles:
    Breathe
      more subdirectories
    Scales
      more subdirectories

我想从、、 AND复制Breathe文件夹及其子目录(它们都在 Animals 文件夹中)。我怎样才能做到这一点?MammalsReptilesbirds

到目前为止,我已经能够遍历文件

for /f %f in ('dir /b C:\users\me\desktop\folder1') do move "breathe"

但这只会返回此错误 3 次:

The system cannot find the file specified

我明白为什么,但我怎样才能解决这个问题,让它真正进入每个文件夹并复制我关心的内容?

标签: filecommand-linecommandcommand-promptmove

解决方案


推荐阅读