Suppose I have the files as below:
c:\tmp\
|_ tony.txt
|_ peter.txt
|_ mary.txt
|_ may.txt
How can I write the .vbs file to batch append TODAY date to the front of the file? The result should look like:
c:\tmp\
|_ 20110630_tony.txt
开发者_Go百科 |_ 20110630_peter.txt
|_ 20110630_mary.txt
|_ 20110630_may.txt
Thanks
Would this get you started? You'll probably want to add some error checking...
Option Explicit
Const FOLDER_PATH = "C:\TMP"
Dim fso, folder, file, newFileName
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(FOLDER_PATH)
For Each file In folder.Files
newFileName = Year(Now) & Right("0" & Month(Now),2) & Right("0" & Day(Now),2) & "_" & file.Name
fso.MoveFile file.Path,file.ParentFolder.Path & "\" & newFileName
Next
精彩评论