I have a script that goes through a folder and finds all files with a .kof extension. I then add a timestamp on the filename. ex.(test.kof to test2005082411.kof)
However, I am getting mixed results on some systems this runs on. On some systems it works fine and others it is renaming way to many times. This is what it looks like on those systems. ex.(test.kof to test2005082411200508241120050824112005082411.kof) It acts like it keeps going through the same directory and finding the file over and over again and keeps renaming it. Sometimes twice sometimes 15 times. Does anybody have any suggestions? Thanks
Test Code below.
_________
Dim oFSO, stagefolder, stagefilelist, koffile, FileExt, FileBase, NewFileName
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set stagefolder = oFSO.GetFolder("C:\test")
Set stagefilelist = stagefolder.Files
timestamp = Year(Now) & Month(Now) & Day(Now) & Hour(Now) & Minute(Now) & Second(Now)
For Each koffile in stagefilelist
FileExt = oFSO.GetExtensionName(koffile)
If (FileExt = "kof") Then
FileBase = oFSO.GetBaseName(koffile)
'WScript.Echo FileBase
NewFileName = FileBase & timestamp & "." & FileExt
'WScript.Echo NewFileName
oFSO.MoveFile koffile, stagefolder & "\" & NewFilename
End If
Next
WScript.Quit
___________
However, I am getting mixed results on some systems this runs on. On some systems it works fine and others it is renaming way to many times. This is what it looks like on those systems. ex.(test.kof to test2005082411200508241120050824112005082411.kof) It acts like it keeps going through the same directory and finding the file over and over again and keeps renaming it. Sometimes twice sometimes 15 times. Does anybody have any suggestions? Thanks
Test Code below.
_________
Dim oFSO, stagefolder, stagefilelist, koffile, FileExt, FileBase, NewFileName
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set stagefolder = oFSO.GetFolder("C:\test")
Set stagefilelist = stagefolder.Files
timestamp = Year(Now) & Month(Now) & Day(Now) & Hour(Now) & Minute(Now) & Second(Now)
For Each koffile in stagefilelist
FileExt = oFSO.GetExtensionName(koffile)
If (FileExt = "kof") Then
FileBase = oFSO.GetBaseName(koffile)
'WScript.Echo FileBase
NewFileName = FileBase & timestamp & "." & FileExt
'WScript.Echo NewFileName
oFSO.MoveFile koffile, stagefolder & "\" & NewFilename
End If
Next
WScript.Quit
___________