Windows Commands: Batch process multiple files


FORFILES-Windows Command

FORFILES

Batch process multiple files

syntax
      FORFILES [-pPath] [-s] [-dDate] [-mMask] [-cCommand] 

key
   -Path   : Path to search                   default=current folder

   -s       : Recurse into sub-folders

   -Date   : This can be
              +DDMMYY to select files newer than a given date
                      (filedate >=DDMMYY) or
              -DDMMYY to select files older than a given date
                      (filedate <=DDMMYY) or
              +DD to select files newer than DD days ago or
              -DD to select files older than DD days ago
-Mask : Search mask (wildcards allowed) default=*.*
-Command : Command to execute on each file. default="CMD /C Echo @FILE" -v : Verbose report


The following variables can be used in -cCommand (must be upper case)

@FILE,
@FNAME_WITHOUT_EXT,
@EXT,
@PATH,
@RELPATH,

@ISDIR,
@FSIZE,
@FDATE,
@FTIME

To ECHO Hex characters in the Command use: 0xHH

Examples:

To find every text file on the C: drive
FORFILES -pC:\ -s -m*.TXT -c"CMD /C Echo @FILE is a text file"

To show the path of every HTML file on the C: drive FORFILES -pC:\ -s -m*.HTML -c"CMD /C Echo @RELPATH is the location of @FILE"

List every folder on the C: drive
FORFILES -pC:\ -s -m*. -c"CMD /C if @ISDIR==TRUE echo @FILE is a folder"

For every file on the C: drive list the file extension in double quotes
FORFILES -pc:\ -s -m*.* -c"CMD /c echo extension of @FILE is 0x22@EXT0x22" List every file on the C: drive last modified over 100 days ago FORFILES -pc:\ -s -m*.* -d-100 -c"CMD /C Echo @FILE : date >= 100 days"

Find files last modified before 01-Jan-1995 FORFILES -pc:\ -s -m*.* -d-010195 -c"CMD /C Echo @FILE is quite old!" note: '0x22' is hex 22 - the double quote character - put these around any long filenames.

Version 1.0 of FORFILES will only search for files newer than a specified date.
Version 1.1 (described above) can search for file dates Newer or Older then a specified date.

version 1.1 can be downloaded from Microsoft's ftp site

An alternative method of dealing with files older or newer than a specified date is to use ROBOCOPY

Other Windows 98, Windows XP Commands:
addusers , arp , assoc , associate , at , attrib , browstat , cacls , call , cd , change , chkdsk , chkntfs , choice , cipher , cleanmgr , clip , cmd , color , comp , con2prt , copy , date , defrag , del , delprof , dir , diruse , diskcomp , diskcopy , doskey , dsadd , dsmod , echo , endlocal , exit , expand , expand , fc , fdisk , find , findstr , for , forfiles , format , fsutil , ftp , ftype , global , goto , help , hfnetchk , if , ifmember , ipconfig , kill , label , ldifde , local , logevent , logoff , logtime , mapisend , md , mem , mode , monitor , more , mountvol , move , moveuser , msg , msiexec , msinfo32 , mstsc , munge , mv , nbtstat , net , netdom , netsh , netstat , netsvc , now , nslookup , ntbackup , ntrights , path , pathping , pause , perms , ping , popd , portqry , print , prncnfg , prnmngr , prompt , pushd , qgrep , rasdial , rasphone , rd , rdisk , recover , reg , regedit , regsvr32 , rem , ren , replace , rmtshare , robocopy , route , runas , rundll32 , sc , schtasks , sclist , scriptit , set , setlocal , setx , share , shift , shortcut , showgrps , showmbrs , shutdown , sleep , soon , sort , start , su , subinacl , subst , tasklist , time , timeout , title , touch , tracert , type , ver , verify , vol , where , whoami , windiff , winmsd , winmsdp , wmic , xcacls , xcopy ,
Live2Support.com :
Product - Benefits - Features - How Does it Works - Pricing - SSL Certificates - Signup - Contactus - Login - Submit Resources