Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am looking for a batch file that will search a specified folder for files with a specific name, then copy the found files to a new directory.
Basically I have a folder with 100,000 plus documents for all customers and I need to select the files that are for one specific customer from this list and send them the files. So I would like a batch file that can search this folder for files with certain names and copy them to a new folder so I can send just the folder with the files that are for that customer without having to manually search and copy all their specific files.Any help would be appreciated
Thanks,
Cam

here goes...
@echo off
cls
:sets
echo you can say "DefaultSearch" for default folder
echo DONT use ""
set /P SearchIn=what folder shal i search in?:
cls
set DefaultSearch=C:\DefaultSearch\
set /P FileToSearch=what files to search'n copy?:
cls
echo you can say Default for the default folder
echo DONT use ""
set /P CopyTo=where shal i copy to?:
set Default="C:\default folder"
:begin
cd "%SearchIn%"
copy *FileToSearch* "%CopyTo%"
if not %ErrorLevel% == 0 echo some error, errorlevel is %ErrorLevel% & pause
:end
echo um... all done
pause
exit
i could make a log-system 2 if you would want that.. :p

This appears to almost work, with the acception of it only being able to search one file name and once it copys the file it renames it filetosearch.
I need the file names to stay the same, and I need to be able to search for multiple files at a time.
E.g need to search for File2, file25 and file1003, then copy them to the new directory with the same name.Sorry I guess I should have been more clear.

@echo off
setLocal EnableDelayedExpansionif %1'==' echo which files? && goto :eof
pushd c:\srcfor /f "tokens=* delims= " %%a in ('dir/b %1') do (
copy %%a d:\dest
)
=====================================
If at first you don't succeed, you're about average.M2

Hello M2,
Not sure how that batch is suppose to work, can you please explain to me how this one you listed works?
Do I add this to the original one?

"Do I add this to the original one?"
No; use it by itself. On the command line, give a filespec, like:
*.XLS
=====================================
If at first you don't succeed, you're about average.M2

Only if the persons files are all *.xls and noone elses.
I only Batch if possible, 2000 more lines of code, oh well.

![]() |
![]() |
![]() |

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