Script to change file name
Posted on 2007-10-19
I have the following script, which changes the file name.
Const FullPath = "C:\test"
Const Prefix = "Han-Solo"
Dim fso, directory, fileList, oFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set directory = fso.GetFolder(FullPath)
Set fileList = directory.files
For Each oFile in fileList
i = instr(oFile.name, Prefix)
if(i < 1)then
oFile.name = Prefix + oFile.name
This script has been add to a server as a scheduled task to run daily. The script does not work when there is a file has the same name. For example IIS Log files has a file two files name ex071023, so when the script runs it says the file already exist. I need to alter the script so that it skips files with the same name and renames the others. How can I do this?