【问题标题】:search given set of file names.* in all sub directories and copy to another directory在所有子目录中搜索给定的一组文件名。* 并复制到另一个目录
【发布时间】:2012-11-14 15:56:02
【问题描述】:

我需要扩展这个问题:search given set of files and copy to another directory

needToFind.txt 文件中有一组给定的文件名,例如:

myImage1、theImage、parisImage(每行一个文件名)

还有一个名为 /MyImageFolder 的文件夹,其中包含假设其子文件夹及其自身中的 1000 张图像,还包含 myImage1.jpg 、myImage1.png、theImage.jpg、parisImage.jpg、parisImage.png、parisImage.tiff

我想在不查看文件扩展名的情况下找到那些给定的图像名称并将它们复制到另一个目录。

非常感谢

【问题讨论】:

  • @dbenham 需要对我之前的问题进行扩展

标签: windows batch-file cmd dos


【解决方案1】:
@echo off
cd "\MyImageFolder"
for /F "usebackq delims=" %%a in ("needToFind.txt") do (
   for /R %%b in ("%%~Na.*") do copy "%%b" "\anotherFolder"
)

【讨论】:

    【解决方案2】:
    @echo off
    cd "\MyImageFolder"
    for /f "usebackq eol=: delims=" %%F in ("needToFind.txt") do copy "%%~F.*" "\anotherFolder"
    

    如果提供的文件名已经有扩展名,而你想忽略扩展名,你可以使用

    @echo off
    cd "\MyImageFolder"
    for /f "usebackq eol=: delims=" %%F in ("needToFind.txt") do copy "%%~nF.*" "\anotherFolder"
    

    【讨论】:

      猜你喜欢
      • 2021-02-08
      • 1970-01-01
      • 1970-01-01
      • 2020-12-08
      • 2021-10-04
      • 1970-01-01
      • 2020-06-03
      • 2010-09-22
      • 2022-01-02
      相关资源
      最近更新 更多