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

insatiable11

New member
Local time
12:39 PM
Messages
1
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 Computer

OS
Windows 7 32 bit
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 Computer

Computer type
PC/Desktop
OS
Windows 10 x64
CPU
Intel i5-3570K
Motherboard
Asus Maximus V Gene
Memory
Crucial 16GB
Graphics Card(s)
nVidia Geforce 660 GTX
Sound Card
onboard
Monitor(s) Displays
NEC 2490WUXi2
Screen Resolution
1920x1200
Hard Drives
Crucial M4 256GB
PSU
Corsair 650TX
Case
Fractal Design - Define Mini
Keyboard
Filco Majestouch Tenkeyless Black MX
Mouse
Logitech MBJ58
Code:
@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")

exit

:COPY_FILES
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
Instruments
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 Computer

Computer Manufacturer/Model Number
Self built
OS
Windows 7 Ultimate x64
CPU
Intel Pentium Dual Core E5200 2.5GHz (3.77GHz OC)
Motherboard
Asus P5Q-E
Memory
Corsair 4GB DDR2 (4x1GB CM2X1024-6400C4)
Graphics Card(s)
Palit GeForce GTS 250 (1024MB)
Sound Card
On Board (ADI AD2000B 8ch HD)
Monitor(s) Displays
Samsung 32in LCD TV
Screen Resolution
1360x768
Hard Drives
2 x 1TB Samsung 103SJ (Raid0)
2 x External 500GB Samsung 502IJ (NexStar 3 HD Enclosures)
PSU
550W Antec Neo HE 550
Case
Antec P180
Cooling
Xigmatex Red Scorpion CPU Cooler. 3x120mm Fans
Keyboard
Logitech MX5000 Laser (Combo)
Mouse
Logitech MX5000 Laser (Combo)
Internet Speed
ADSL2+ (avg 10 Mbps Down, 0.80 Mbps up)
Other Info
Gigabyte GN-WP01GS 54g Wireless Lan Card
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.
Code:
@echo off

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

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

pause
exit

:COPY_FILES
for %%i in (%1) do set DEST=%%~ni
for /f "usebackq delims==" %%i in (%1) do xcopy /qv "%FILESPATH%\%%i" "%DESTPATH%\%DEST%\*"
 

My Computer

Computer Manufacturer/Model Number
Self built
OS
Windows 7 Ultimate x64
CPU
Intel Pentium Dual Core E5200 2.5GHz (3.77GHz OC)
Motherboard
Asus P5Q-E
Memory
Corsair 4GB DDR2 (4x1GB CM2X1024-6400C4)
Graphics Card(s)
Palit GeForce GTS 250 (1024MB)
Sound Card
On Board (ADI AD2000B 8ch HD)
Monitor(s) Displays
Samsung 32in LCD TV
Screen Resolution
1360x768
Hard Drives
2 x 1TB Samsung 103SJ (Raid0)
2 x External 500GB Samsung 502IJ (NexStar 3 HD Enclosures)
PSU
550W Antec Neo HE 550
Case
Antec P180
Cooling
Xigmatex Red Scorpion CPU Cooler. 3x120mm Fans
Keyboard
Logitech MX5000 Laser (Combo)
Mouse
Logitech MX5000 Laser (Combo)
Internet Speed
ADSL2+ (avg 10 Mbps Down, 0.80 Mbps up)
Other Info
Gigabyte GN-WP01GS 54g Wireless Lan Card
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 Computer

OS
windows 7 home premium 32 bit
Use the Image finder,
by Fundy Software
This program has been discontinued

Run as Adobe Air
 

Attachments

My Computer

Computer type
PC/Desktop
OS
ultimate x64
Not working it says :

FILE NOT FOUND
 

My Computer

Computer type
PC/Desktop
OS
7 64 bit PRO
Back
Top