I have a vb script where I need to change file extension for all files that starts with t* and that have extension = .txt. Here is the code I have but it does not work right (It works fine when I only have .txt but then it picks up more files than I want)
Dim filesys, file, folderName, objFile, folderObj, fileColl, objRegExp, newFile
Set filesys = CreateObject("Scripting.FileSystemObject")
folderName = "c:\myfolder\myftpfolder\"
Set folderObj = filesys.GetFolder(folderName)
Set fileColl = folderObj.Files
Set objRegExp = New RegExp
objRegExp.Pattern = "t*.txt" 'looking for t*.txt (extension) match
objRegExp.IgnoreCase = True
For Each objFile In fileColl
If objRegExp.Test(objFile.Name) Then
newFile = objRegExp.Replace (objFile.Name, ".bak")
filesys.MoveFile objFile, folderName & newFile
End If
Next
Dim filesys, file, folderName, objFile, folderObj, fileColl, objRegExp, newFile
Set filesys = CreateObject("Scripting.FileSystemObject")
folderName = "c:\myfolder\myftpfolder\"
Set folderObj = filesys.GetFolder(folderName)
Set fileColl = folderObj.Files
Set objRegExp = New RegExp
objRegExp.Pattern = "t*.txt" 'looking for t*.txt (extension) match
objRegExp.IgnoreCase = True
For Each objFile In fileColl
If objRegExp.Test(objFile.Name) Then
newFile = objRegExp.Replace (objFile.Name, ".bak")
filesys.MoveFile objFile, folderName & newFile
End If
Next