Tag Archives: windows

Find files using forfiles in windows

Few days back I had to accomplish yet another task, finding some files among large data.

The problem was internal windows search function was very slow and it requires indexing (Which we disabled to save resources on server). In linux you can use find command to find the files you are looking for by using following command

find /opt/data -name "*.c"

This will find all the files with c extension under /opt/data directory on Linux. But unfortunately I was on windows and had to improvise. So I remember forfiles utility and used it to find files under D:\data directory on windows using following syntex.

forfiles /P d:\data /M *.c /S /C "cmd /c echo @path

I am sharing this syntex so that it might help somebody.

Please comment your views so that I can also learn a trick or two ;)

Migrating data with robocopy

Few days back I had a situation when I needed to migrate data from one Windows 2003 server to another.

The data contained 2 level of directories and thousands of files in them.

Also the data needed to copied with ACL as well.

so I wrote a script on source server as below to speed up copy.


cd D:\data

For /D %%r in (*) do (

For /D  %%a in (*) do(

cd %%a

start robocopy.exe D:\data\%%r\%%a \\destination\data\%%r\%%a *.* /e /s /w:3 /r:3 /XX /XO /SEC /LOG:c:\robocopy_%%r_%%a.log)


I created log file to retain the dir and files list which were copied.

What I did with script is I queried for all directories in D:\data and I again queried the directories under D:\data\DIRECTORIES.

Then I used robocopy utility from Windows server kit to start copying each directories and files at the same time with start command.

If you don’t put start in front of robocopy it will still copy, but it will copy one directory at a time.

Hope this solution will help some other people who may require it.

Please comment suggestions for improvement or what solution you would use to complete this kind of task.