압축하는 스크립트

업데이트시 해당 파일 및 폴더를 운영하는 섭에 올리기 전에 베타섭에 올려서 테스트를 하게되는데
이것은 그 파일및 폴더를 압축하는 스크립트다. 일단 srcFolder에 현재날짜의 폴더가 존재하여야 압축이 된다.  그리고 압축하는 프로그램이 있어야한다. 여기서는 arj를 이용했다.
받는 곳은 http://www.arjsoftware.com/  여기다.
 
 
Option Explicit

Dim
currDate, objShell, intReturn, srcFolder, objFSO, srcFolders, ConvertDate, strLog

Set objShell   = WScript.CreateObject("WScript.Shell")
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")

intReturn
= 0

currDate = DateAdd("d", 0 , Date)                        '  2007-08-30 형식으로 된다.
ConvertDate  = ConvertDate8(currDate)                '  날짜를 8자리로 변경
srcFolder = "C:\BackUp_ftp\Update"

If objFSO.FolderExists(srcFolder & "\" & ConvertDate ) Then  ' 현재 날짜의 폴더가 존재하면 그 폴더를 압축한다.
   
objShell.Run("arj32 a -r " & ConvertDate & " " & ConvertDate)
    strLog
= "1 개의 파일이 압축되었습니다. - " & ConvertDate & ".arj" & vbCrLf    
Else
   
strLog = "업데이트가 없습니다." & vbCrLf    
End If


Function
ConvertDate8(Byval currDate)                 ' ex) 2007-08-30 를 20070830 로 변경
   
If IsDate(currDate) Then
       
ConvertDate8 = Replace(FormatDateTime(currDate, 2), "-", "")
   
Else
       
ConvertDate8 = ""
   
End If
End Function


Dim
objLog
   
Set objLog = objFSO.OpenTextFile(srcFolder & "\log\Compress_" & Replace(FormatDateTime(Date, 2), "-", "") & ".log", 2, True)   ' 로그파일 남기기

objLog.Write strLog
objLog.Close