sarch through folders

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
 
F

foxidrive

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
 
G

Guest

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,
 
F

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.

You can use xxcopy to 'flatten' a folder structure. It modifies any
filenames that might clash. http://www.xxcopy.com
 
J

Jerold Schulman

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top