sarch through folders

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
In a batch file I need it search all the folders under c:\root\ and find all
the *.csv files and copy them to l:\root periodically.

How can I do this is a batch file?
Thanks
 
Hello,
In a batch file I need it search all the folders under c:\root\ and find all
the *.csv files and copy them to l:\root periodically.

How can I do this is a batch file?
Thanks

Something like this:

xxcopy c:\*.csv L:\ /s
 
Hi foxidrive ,

Thanks for your reply. This will copy everything to destination with the
folders. I need to copy each file to a specific destination not creating the
same folders in the destination folder. I need to loop though folder from
source side, find the files and if any, copy them to a folder.

Thanks,
 
Thanks for your reply. This will copy everything to destination with the
folders. I need to copy each file to a specific destination not creating the
same folders in the destination folder. I need to loop though folder from
source side, find the files and if any, copy them to a folder.

You can use xxcopy to 'flatten' a folder structure. It modifies any
filenames that might clash. http://www.xxcopy.com
 
Hello,
In a batch file I need it search all the folders under c:\root\ and find all
the *.csv files and copy them to l:\root periodically.

How can I do this is a batch file?
Thanks

In addition to foxidrive's solution, if you need more control, you can use the following batch.

@echo off
setlocal
for /f "Tokens=*" %%f in ('dir /s /a /b c:\root\*.csv') do (
call :copyit "%%f"
)
endlocal
goto :EOF
:copyit
set file=%~nx1
copy %1 "L:\Root\%file%" /Y

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 
Back
Top