搜索给定的文件名。*在所有的子目录,并复制到另一个目录 [英] search given set of file names.* in all sub directories and copy to another directory

查看:101
本文介绍了搜索给定的文件名。*在所有的子目录,并复制到另一个目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要扩展到这个问题:<一href=\"http://stackoverflow.com/questions/13333937/search-given-set-of-files-and-copy-to-another-directory\">search给定的文件,并复制到另一个目录

有处于needToFind.txt文件,如给定的文件名:

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

和有一个名为/ MyImageFolder文件夹,其中包含让说,在其子文件夹1000的图像和本身,也包含myImage1.jpg,myImage1.png,theImage.jpg,parisImage.jpg,parisImage.png,parisImage.tiff

我要找到那些特定的图片名称不看文件的扩展名,并将其复制到另一个目录。

非常感谢


解决方案

 关闭@echo
CD\\ MyImageFolder
FOR / F有usebackq EOL =:delims =%% f由于(needToFind.txt)并复制%%〜F. *\\ anotherFolder

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

 关闭@echo
CD\\ MyImageFolder
FOR / F有usebackq EOL =:delims =%% f由于(needToFind.txt)并复制。%%〜nF的*\\ anotherFolder

I need extension to this question: search given set of files and copy to another directory

There is a given set of file names in a needToFind.txt file such as:

myImage1 , theImage, parisImage (one file name per line)

And there is a folder named /MyImageFolder, which contains lets say 1000 images in its subfolders and itself, and also contains myImage1.jpg ,myImage1.png, theImage.jpg, parisImage.jpg, parisImage.png,parisImage.tiff

I want to find those given image names without looking file extension and copy them to another directory.

Thanks a lot

解决方案

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

If the provided file names already have extensions, and you want to ignore the extensions, you can use

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

这篇关于搜索给定的文件名。*在所有的子目录,并复制到另一个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆