This script can rename multiple files in a specific folder.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
'You connect to default namespace with moniker method(winmgmt)
Set colFileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='C:\Logs'} Where " _
& "ResultClass = CIM_DataFile")
'it seems little different.It connects two wmi class in one command.uses Win32_Directory class for retrieving folder ,uses CIM_Datafile for files.Associators of usage connects two class like joining two db table.
For Each objFile In colFileList
strNewName = objFile.Drive & objFile.Path & "ABC-" & _
objFile.FileName & "." & objFile.Extension
errResult = objFile.Rename(strNewName)
Next
'this is very simple you assign new file name to strNewName variable.You can add prefix or suffix in here.
WMI scripts-rename multiple files in a folder
Etiketler:
associator of,
rename multiple file,
script,
wmi