VBScript - Pad Digits with Leading Zeros

Environment
  • Microsoft Windows XP
Introduction
Just copy from  ASP FAQ for making use this rename file name like the following
filename.YYYYMMDDHHmm
Dim oFSO, oFileSet oFSO = CreateObject("Scripting.FileSystemObject")

Set oFile = oFSO.GetFile(WHICH_FILE)

fileName = oFile.Name & "." & YEAR(Date()) & padDigits(Month(date()),2) & padDigits(DAY(date()),2) & padDigits(Hour(Now()), 2) & padDigits(Minute(Now()), 2)
Codes
'Param int n
'Param int totalDigits
'Return String padDigits
Function padDigits(n, totalDigits)
    If totalDigits > Len(n) Then
        padDigits = String(totalDigits - Len(n), "0") & n
    Else
        padDigits = n
    End If
End Function
Reference
  • http://classicasp.aspfaq.com/general/how-do-i-pad-digits-with-leading-zeros.html