更新脚本以提高效率。 JAL脚本在循环中调用VBScript来检查txt文件中的每个文件。
我需要帮助的是获取文件名,将FormattedDT(日期/时间)添加到它(原始文件名是FullFileName),然后将其复制到存档文件夹(\ a70tsgnaeasa001 \ eas \ server \ log) \存档)。例如,如果它正在读取的txt文件中的文件名是\ A70TSGNAEASA001 \ d $ \ EAS \ Server \ FIPS \ BCBSFIPS.TXT,它最后一次修改时间是10/27/2017 3:00,那么我希望目的地是\ a70tsgnaeasa001 \ eas \ server \ log \ archive \ BCBSFIPS_10_27_2017_03_00_00.TXT
我无法弄清楚如何删除.extension,附加文件的日期/时间,然后将其复制到存档文件夹。我把目前为止的代码放在下面。
TIA
TXT文件格式
REM there is a comment here on the first line \\filepath1 \\filepath2 ... \\filepathN
的VBScript:
option explicit
Dim SFSO, WSSL, FullFileName, txtFile, exitCode, txtLine, ArchiveFolder,
CopyFileName
Dim ArchDT, FormattedDT, mon, day, yr, hr, min, sec, empty
Set ArchiveFolder, "\\\\A70TSGNAEASA001\\eas\\Server\\log\\Archive\\"
Set SFSO = CreateObject("Scripting.FileSystemObject")
Set WSSL = Wscript.CreateObject("WScript.Shell")
exitCode = 0
'tests for no args
If WScript.Arguments.Count = 0 then
WScript.quit (9999)
End If
txtFile = WScript.Arguments(0)
Set f = SFSO.OpenTextFile(txtFile)
On Error Resume Next
Do Until f.AtEndOfStream
txtLine = f.ReadLine
If(Left(txtLine,2) == "\\")
FullFileName = txtLine
' Check for file exists
If SFSO.fileexists(FullFileName) then
' Check file status
If VarType(SFSO.OpenTextFile(FullFileName,8,False)) = vbError Then
exitCode = 9999
Else
' create archive folder path
'get modified date time, format to _mm_dd_yyyy_hh_mm_ss
ArchDT = CDate(SFSO.DateLastModified(FullFileName))
mon = Month(ArchDT)
day = Day(ArchDT)
yr = Year(ArchDT)
hr = Hour(ArchDT)
min = Minute(ArchDT)
sec = Second(ArchDT)
FormattedDT = "_"&mon&"_"&day&"_"&yr&"_"&hr&"_"&min&"_"&sec
' File name with date/time appended to it
'Part I'm having trouble with
'copy file to archive folder (how I would copy the file)
' SFSO.CopyFile(FullFileName, CopyFileName)
End If
Else
exitCode = 9999
End If
End If
Loop
f.Close
Err.Clear
SFSO.Close
WScript.quit(exitCode)