问题
There is a given set of file names in a needToFind.txt file such as:
myImage1.jpg , theImage.jpg, parisImage.jpg (This is a flie that I will format it does not matter filee names are seperated with comma, or line break)
And there is a folder named /MyImageFolder, which contains lets say 1000 images, and also contains myImage1.jpg , theImage.jpg, parisImage.jpg
I want to find those given images and copy them to another directory.
I want to search given file names in needToFind.txt, in a directory/folder MyImages, which contains many images. And copy founded images to another directory/folder, such as MyGivenSetOfImages.
Please help, this will save my life.
Thanks
回答1:
Format needToFind.txt to have one file name per line. The following simple batch script should work.
@echo off
cd "\MyImageFolder"
for /f "usebackq eol=: delims=" %%F in ("needToFind.txt") do copy "%%~F" "\anotherFolder"
It can be done on the command line without a batch file: just change each %%
to %
.
回答2:
I guess the trickiest part is to read the file
If you can , i would advice you to create text files with all names in a single lime seperated by a comma.
refer how to read a text file through batch for that
Later you could simply use the extracted variables in a simple copy
command.
i could have provided a skeleton , but on a phone. I hope this helps open for questions
来源:https://stackoverflow.com/questions/13333937/search-given-set-of-files-and-copy-to-another-directory