Hi all
i have a script that im trying to run that looks in a folder and renames the files in there based on the first 9 characters of their existing filename. For example the files are called:
ABCDEFG-2006-09-09.xxx
I want just the first 7 characters (ABCDEFG) and then the file extension .xxx ive tried the following but it does not seem to do anything?
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='C:\test'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In colFiles
strStart = left(objFile.Name, 9)
strNewName = objFile.Drive & objFile.Path & strStart & ".ucs"
errResult = objFile.Rename(strNewName)
Next
The folder c:\test does exist. Any help would be appreciated but im a newbie to VBscript so be gentle!
Regards
Rob
i have a script that im trying to run that looks in a folder and renames the files in there based on the first 9 characters of their existing filename. For example the files are called:
ABCDEFG-2006-09-09.xxx
I want just the first 7 characters (ABCDEFG) and then the file extension .xxx ive tried the following but it does not seem to do anything?
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='C:\test'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In colFiles
strStart = left(objFile.Name, 9)
strNewName = objFile.Drive & objFile.Path & strStart & ".ucs"
errResult = objFile.Rename(strNewName)
Next
The folder c:\test does exist. Any help would be appreciated but im a newbie to VBscript so be gentle!
Regards
Rob