Kimberly1467
asked on
Script to change multiple file names
I need to know how to write a script that will change the name of my logfiles. For example if I have the following files:
ex071014log.txt
ex071015log.txt
I want to change each one to:
Han-Soloex071014log.txt
Han-Soloex071015log.txt
In essence I want to add Han-Solo in front of the original file name.
Can this be done, if so how?
ex071014log.txt
ex071015log.txt
I want to change each one to:
Han-Soloex071014log.txt
Han-Soloex071015log.txt
In essence I want to add Han-Solo in front of the original file name.
Can this be done, if so how?
ASKER
basicinstinct,
That works great! But I want to add this to a scheduled task that runs everyday at 10:00 am. But when I do this the file name that was change the day before to Hans-Soloex071024log now becomes Han-SoloHanSoloex071024log . Is there a way not change the file name of those that have previously been changed?
That works great! But I want to add this to a scheduled task that runs everyday at 10:00 am. But when I do this the file name that was change the day before to Hans-Soloex071024log now becomes Han-SoloHanSoloex071024log
are you asking for a shell or VB script?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim FullPath
FullPath = "C:\path\to\your\folder"
Dim fso, directory, fileList, oFile
Set fso = CreateObject("Scripting.Fi
Set directory = fso.GetFolder(FullPath)
Set fileList = directory.files
For Each oFile in fileList
oFile.name = "Han-Solo" + oFile.name
Next