Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: search multiple files, copy+paste to new folder (batch file software?)

03 May 2012   #1

Windows 7 32 bit
search multiple files, copy+paste to new folder (batch file software?)

I am a complete newbie when it comes to batch files and batch file software, so apologies in advance.

I've done some research on Google etc but I seem to just be getting more and more confused trying to use various different scripts and programs and reading different info on various websites.

This is what I need...

I have a folder with around 2000 files in it. I want to be able to copy certain files from this folder (normally around 40) and place them in a brand new folder, I want to be able to do this with nothing more than a txt file that has all the file names I need copying in it with every file name on a separate line.

I receive around 10 new txt files each day so you can imagine how tedious it is searching through 2000 files, picking out the 40 I need, 10 times a day everyday.

To make things even more complicated, the txt files I receive don't always have the correct file names in them, maybe there's a misspelling or a word or two missing for some of the names. That's ok when I'm going through picking out the files I need to copy myself because I can normally tell which file is being requested, but I can't see it being so easy for a program or whatever to do, I'm guessing it'll need to have a search feature where it picks out the most likely file.

I'd like it to be as automated as possible. I receive the txt file, make sure each file name is on a separate line then a program or script or whatever goes out and picks out the files (or most likely files for the name's that aren't exact matches) and copies them into a brand new folder (which I'd like to be the same name as the text file it's using to choose the files).

I hope this makes sense, I've probably made it sound a lot more complicated than I needed to, I've been looking for a solution for weeks now so my brains gone a bit foggy :/

I'd appreciate any help you can offer!

My System SpecsSystem Spec
03 May 2012   #2

Windows 10 x64

Contact Rent-A-Coder, Elance, or any of the other programming for hire sites. They could knock this out pretty quickly I would think.
My System SpecsSystem Spec
04 May 2012   #3

Windows 7 Ultimate x64

@echo off
rem Text file with filenames
rem To be prompted for this change to  'set /p LIST=Path to text file: '
rem Or 'set LIST=%1' to run from cmd line like, filename.bat "D:\List.txt"
set LIST="D:\List.txt"

rem Path to the files to copy
rem Can be change the same as LIST
rem Or 'set FILESPATH=%2' to run like , filename.bat "D:\List.txt" "D:\Test"
set FILESPATH="D:\Test"

rem Destination path can be added here. eg set DESTPATH=C:\New Folder
rem If set change xcopy cmd to "%DESTPATH%\%DEST%\*"
rem Do not use quotes when setting DESTPATH

rem Set Destination folder based on LIST name
for %%i in (%LIST%) do set DEST=%%~ni

rem Read LIST and call :COPY_FILES for each line passing the line of text
for /F "usebackq delims==" %%i in (%LIST%) do (call :COPY_FILES "%%i")


rem Destination folder created in same location the batch file is run from
xcopy /qv %FILESPATH%\%1 .\%DEST%\*
This is a simple batch file that will do the first part but for the incorrect filenames thats a lot harder.

There's only two options that I think will work with this script and that's to create a text file of any files that are not found (incorrect names) then manually copy them or using substrings with wildcards which probably won't work very well.

You might have better luck asking on a scripting forum but I don't think so. The problem I see is to find possible matches you need to break the string up and find files that contain the broken up parts of the string and use wildcards.

For example you had the file listed as "Seven orums" and you had the files
Seven Dwarfs
The Last Seven
Seven Forums

Now if you search for Seven* (* = any char) then it would return Seven Dwarfs and Seven Forums. If you search for *orums, it would return Seven Forums.

But how do we break it up,
*rum* = Instruments
Sev* = Seven Dwarfs, Seven Forums
*Sev* = Seven Dwarfs, The Last Seven, Seven Forums
ven* = Nothing
*en oru* = Nothing

To many possibilties and out of 2000 files how many would be returned with partital matches?

I don't know if there would be any 3rd party software that could do this either.
My System SpecsSystem Spec

04 May 2012   #4

Windows 7 Ultimate x64

Improved code for multiple List files in one folder. I left the old code there because the comments are still valid except the destination path is included in this one.
@echo off

set LISTFOLDER=D:\List Files
set DESTPATH=D:\New Folder

for /f "tokens=*" %%i in ('dir /b ^"%LISTFOLDER%\*.txt^"') do (call :COPY_FILES "%LISTFOLDER%\%%i")


for %%i in (%1) do set DEST=%%~ni
for /f "usebackq delims==" %%i in (%1) do xcopy /qv "%FILESPATH%\%%i" "%DESTPATH%\%DEST%\*"
My System SpecsSystem Spec
18 Oct 2012   #5
Bobbo Jones

windows 7 home premium 32 bit

To revive this thread, i also have this need. Ie, folders with thousands of file names to search through in the hope of copying 20 of them into a new folder. Unlike Insatiable 11, my file names are reliably correct.

My journey of understanding batch scripts began this morning.
Can anyone recommend a thread/tutorial, which can help me interpret Duzzy's posts, so I can create a working batch file using his recommended formulas?

cheers all..
My System SpecsSystem Spec
20 Oct 2012   #6
Bobbo Jones

windows 7 home premium 32 bit

My System SpecsSystem Spec
23 Jul 2017   #7

ultimate x64

Use the Image finder,
by Fundy Software
This program has been discontinued

Run as Adobe Air

Attached Files
File Type: rar Image-Finder-v2.rar (876.3 KB, 43 views)
My System SpecsSystem Spec
01 Sep 2017   #8


I have no idea.
My System SpecsSystem Spec
06 Oct 2017   #9

7 64 bit PRO

Not working it says :

My System SpecsSystem Spec
12 Sep 2018   #10


Quote   Quote: Originally Posted by Rander View Post
Use the Image finder,
by Fundy Software
This program has been discontinued

Run as Adobe Air
I cant't thank you enough for gr8 help.
My System SpecsSystem Spec

 search multiple files, copy+paste to new folder (batch file software?)

Thread Tools

Similar help and support threads
Thread Forum
select/search multiple files, copy and paste to a new folder
I have a list of 1000 files names. Need to find them in one folder which has 5000+ files in it. Any possible way to highlight those files from my list so I can copy paste to a new folder?
General Discussion
How do you select non consecutive files in a folder to copy and paste?
I have categorized folders of thousands of pictures and every once in a while I need to sort through and certain files for a specific project. The way I've been doing this is to select one file at a time or if there happens to be a consecutive run of pictures I can grab the whole group and then...
General Discussion
select/search multiple files from a list, copy and paste to new folder
I have a list of 1000 files names (photo files) from clients and need to find them in one folder which has 10000+ files in it.And my clients files list do not have the full photo name (only a part of file name, eg: the file name in my local disk is "403817-QTX0022-30763812_Q10Photo.jpeg" and name...
General Discussion
copy/paste multiple files get really slow
Hi guys, Recently,I noticed a significant drop in speed when copy/paste more than one files,as in the chart below.Then I tried fastcopy,and it seems my hard drives work fine. So what is wrong with explorer.exe ? Thanks!
Performance & Maintenance
Need a Batch File to Copy to a Custom Dest Folder
I need help with a batch file to copy the contents of my source dir to the destination dir that is to be created with that days date using xcopy or robocopy. Any help is appreciated!
Network & Sharing

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 08:14.
Twitter Facebook Google+