Windows server 2003 and Windows XP – How to use advanced search for files via command line

Posted by aidas | Posted in Command line, Tools, Windows 2003, Windows XP | Posted on 13-08-2009

0

Windows server 2003 has very nice tool “forfiles.exe” which provides you with quick and nice file search function.

If you want to use it with your Windows XP machine download it from here .

This tool can be played with mass of functions and in this article i`ll show how to use it with some of them.

For example i want to search through all *.log files in C:\Windows folder and subfolders.

If i find any *.log file there that size is greater than 1MB i want to export  path, size and modify time information of that file into C:\Data\LogFileInfo.txt .

In that case open command line and type:

forfiles.exe /p C:\Windows /s /m *.log /c “cmd /c IF @fsize GTR 1000000 (echo @path @fsize @fdate)” >C:\Data\LogFileInfo.txt

Syntax:

/p – what path to search
/m – what file type to search
/s – include subfolders
GTR – greater than