Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I have a directory called C:\Bankfiles. Each day this directory is populated with new .txt files. The file names are never the same since these are validation reports, and thus generated by the bank. One day a file name could be jgh10042.txt and the next day it could be ght44589.txt. Here is what I want to do. Search inside all of these .txt files in C:\Bankfiles for customer number "TDCUST022" and whichever file contains this search string, copy it to a folder called C:\CustFound. So far I have tried the DOS Find command:
Find /c "TDCUST022" C:\BankFiles
This produces the following:
D:\BatTest>find /c "TDMAR10202" D:\Battest\*.txt
---------- C:\BankFiles\JKH47226.TXT: 0---------- C:\BankFiles\JOH43285.TXT: 0
---------- C:\BankFiles\JOH55272.TXT: 1
So as you can see, the last file (JOH55272.TXT) is the file I want to copy to C:\CustFound. How do I do this ?

This should do it:
for %%? in (C:\Bankfiles\*.txt) do (
FIND "TDMAR10202" < %%~fs? > nul
if not errorlevel=1 (
copy %%~fs? C:\CustFound
goto fend
)
)
:fend-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
The sblaster command
|
Dos Client AutoConnect
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |