#1
|
||||
|
||||
![]()
In Excel VBA, I know how to get the timestamp of a file, and append a formatted date to that existing file.
In VBS through SecureCRT, I want to do the same thing. How do I test if a file exists? (I know how to do that - the snip below works as far as telling me I need to add code.) If the file exists, How do I rename that existing file by appending that file's formatted date? (Figured it out) This is my skeleton so far: Code:
Set fso = CreateObject("Scripting.FileSystemObject") Select Case fso.FileExists(strOutputPath & strOutputFile) Case True Select Case crt.Dialog.MessageBox("File exists - Save dated copy?", "SAVE FILE?", vbYESNO + vbQUESTION) Case vbYESc Set f = fso.GetFile(strOutputPath & strOutputFile) strFileDate = f.DateCreated strFileDate = Year(strFileDate) & "-" & _ Right("0" & Month(strFileDate),2) & "-" & _ Right("0" & Day(strFileDate),2) crt.Dialog.MessageBox "Date on existing file: " & vbCrLf & _ strFileDate & vbCrLf & vbCrLf & _ "PATH: " & strOutputPath & vbCrLf & _ "OLD: " & strOutputFile & vbCrLf & _ "NEW: " & Left(strOutputFile, InStrRev(strOutputFile, ".")) & strFileDate & Mid(strOutputFile, InStrRev(strOutputFile, ".")) fso.MoveFile strOutputPath & strOutputFile, strOutputPath & Left(strOutputFile, InStrRev(strOutputFile, ".")) & strFileDate & Mid(strOutputFile, InStrRev(strOutputFile, ".")) Case vbNOc ' NOOP End Select Case False ' NOOP End Select I had to search multiple pieces, and it's hard to know what is different between SecureCRT-VBS and MS-VBS. But, the code as shown works as desired. If anyone has suggestions on how to improve it, please rovide. Last edited by Rhudi; 09-01-2020 at 11:52 AM. Reason: [SOLVED] |
#2
|
|||
|
|||
Hi Rhudi,
Are you seeking assistance with something? If so, it's not clear what exactly your question is and how it involves one of our products. Please clarify.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
||||
|
||||
Clarification
I edited my post to actually ask my question. :P
|
#4
|
|||
|
|||
Hi Rhudi,
Quote:
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | Rate This Thread |
|
|