add hour minute second year to file name

I am by no means completely fluent in VS scripting but this one should be that hard.  I have attached the full script below but I would think this should be as simple as changing the script below.  I have made the change but the file name isnt updating to add the Month Year change
 
HourMinuteSecond = Hour(Now) & Minute(Now) & Second(Now)
to show
HourMinuteSecondMonthYear = Hour(Now) & Minute(Now) & Second(Now) & Month(Now) & Year(Now)
and do a find replace for HourMinuteSecond to HourMinuteSecondMonthYear


For Each File In fsoFiles
            If File.Name <>  "ScanUpload.txt" Then
                  HourMinuteSecond = Hour(Now) & Minute(Now) & Second(Now)
                  FileCountProcessed = FileCountProcessed + 1
                  NameArray = Split(File.Name, "_", - 1, 1)
                  ArraySize = UBound(NameArray,1)
                  If ArraySize > 0 Then
                        Select Case ArraySize
                              
                        Case "1"
                              DocType = Trim(Mid(NameArray(1), 1, InStr(1, NameArray(1), ".") - 1))
                              AppID = Trim(NameArray(0))
                              Comment = AppID & " - " & "Auto Uploaded Document"
                              DestinationFileName = AppID & "_" & DocType & "_" & HourMinuteSecond & "AUPLD.pdf"
                              
                        Case "2"
                              DocType = Trim(NameArray(1))
                              AppID = Trim(NameArray(0))
                              Version = Trim(Mid(NameArray(2), 1, InStr(1, NameArray(2), ".") - 1))
                              Comment = AppID & " - " & "Auto Uploaded Document"
                              DestinationFileName = AppID & "_" & DocType & "_" & Version & "_" & HourMinuteSecond & "AUPLD.pdf"
                              
                        Case "3"
                              DocType = Trim(NameArray(1))
                              AppID = Trim(NameArray(0))
                              Version = Trim(NameArray(2))
                              CommentCode = Trim(Mid(NameArray(3), 1, InStr(1, NameArray(3), ".") - 1))
                              If UCase(commentcode) = "NE" Then
                                    Comment = AppID & " - " & "Non Executed Loan Closing Document"
                                    DestinationFileName = AppID & "_" & DocType & "_" & Version & "_" & CommentCode & "_" & HourMinuteSecond & "AUPLD.pdf"
                              ElseIf UCase(commentcode) = "SDW" Then
                                    Comment = AppID & " - " & "Summary Decline Worksheet"
                                    DestinationFileName = AppID & "_" & DocType & "_" & Version & "_" & CommentCode & "_" & HourMinuteSecond & "AUPLD.pdf"
                              ElseIf UCase(commentcode) = "SDL" Then
                                    Comment = AppID & " - " & "Summary Decline Letter"
                                    DestinationFileName = AppID & "_" & DocType & "_" & Version & "_" & CommentCode & "_" & HourMinuteSecond & "AUPLD.pdf"
                              Else
                                    Comment = AppID & " - " & "Auto Uploaded Document"
                                    DestinationFileName = AppID & "_" & DocType & "_" & Version & "_" & HourMinuteSecond & "AUPLD.pdf"
                              End If
                              
                        End Select
                        
                              If Len(AppID) = 11 And Mid(File.Name, 1, 1) = "L" And IsNumeric(DocType) Then
                                          On Error Resume Next
                                          fso.MoveFile DriveSpec & File.Name, Samba_DriveSpec & DestinationFileName
                                          If Err = 0 Then
                                                LogCount = LogCount+1
                                                Call WriteTransUploadFile      
                                          Else
                                                Call WriteFileErrorFile(DriveSpec & File.Name, File.Name)
                                                Err.Clear
                                          End If
                                          On Error Goto 0
                              Else
                                    If Len(AppID) = 10 And IsNumeric(AppID) And IsNumeric(DocType) Then
                                          On Error Resume Next
                                          fso.MoveFile DriveSpec & File.Name, Samba_DriveSpec & DestinationFileName
                                          If Err = 0 Then
                                                LogCount = LogCount+1
                                                Call WriteTransUploadFile
                                          Else
                                                Call WriteFileErrorFile(DriveSpec & File.Name, File.Name)
                                                Err.Clear
                                          End If
                                          On Error Goto 0
                                    Else
                                          Call WriteApplicationIDErrorFile(DriveSpec & File.Name, File.Name)
                                    End If
                              End If
                  Else
                                          Call WriteApplicationIDErrorFile(DriveSpec & File.Name, File.Name)
                  End If
                  Else
                        FileCountProcessed = FileCountProcessed + 1
                  End If
            Next
      
sbapdcirmAsked:
Who is Participating?
 
RobSampsonCommented:
Hi, instead of
Hour(Now)

use
Hour(FormatDateTime(Time, vbShortTime))

Regards,

Rob.
0
 
BidonetCommented:
Try first by replacing

HourMinuteSecond = Hour(Now) & Minute(Now) & Second(Now)

Open in new window


with

HourMinuteSecond = Hour(Now) & Minute(Now) & Second(Now) & Month(Now) & Year(Now)

Open in new window


And see what happens
0
 
sbapdcirmAuthor Commented:
I was able to get the my original script to work but one question I have is does this show the Hour in a 24 hour time format for a 12 hour time format?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.