VBScript - Pad Digits with Leading Zeros
Environment
Just copy from ASP FAQ for making use this rename file name like the following
- Microsoft Windows XP
Just copy from ASP FAQ for making use this rename file name like the following
filename.YYYYMMDDHHmm
Dim oFSO, oFileSet oFSO = CreateObject("Scripting.FileSystemObject")Codes
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)
'Param int nReference
'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
- http://classicasp.aspfaq.com/general/how-do-i-pad-digits-with-leading-zeros.html