WMI VBScript to rename files

I needed to watch a directory for incoming files, then rename the files sequentially and move them. Here’s how I did it.

int i

for i = 1 to 10000  
    strComputer = "."  
  
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")  
  
    Set colFiles = objWMIService.ExecQuery("Select * From CIM_DataFile Where Path = '\scripts\' and Extension = 'pdf'")  
  
    For Each objFile in colFiles  
     strNewName = objFile.Drive & objfile.path & "\new\" & i & ".pdf"  
     errResult = objFile.copy(strNewName)    
     objfile.delete  
      
    Next  
  
    wscript.sleep 3000  
  
    'Wscript.echo "done " & i  
 next