1c8

VBS. , , . .

, . .

.

DaysForStore

ArcHEvery

IsCompessing .

.

ARC .

 

.

, ( ) DaysForStore.

, ARC.

IsCompessing, RAR, RAR- .

.

, . , , DaysForStore.

, . , . .

, .. 1.

, , . , .

 

2 .

 

 

' 20110913. , .

 

 

 

'=== ===

DaysForStore7 = 7 '

ArcHEvery = 4 '

IsCompessing = false ' ()

 

 

 

'=== ===

 

' ...

on error resume next

 

Set fso = CreateObject("Scripting.FileSystemObject")

 

 

PathToBase = fso.GetParentFolderName(WScript.ScriptFullName)

 

 

 

base = PathToBase & "1Cv8.1CD" '

PathToArcFolder = PathToBase & "arc" '

isExist = FSO.FolderExists(PathToArcFolder)

If isExist = False Then

Set PathToArc = FSO.CreateFolder(PathToArcFolder)

Else

End If

PathToArc = PathToArcFolder & ""

'

NeedToBackup = False

 

 

'

 

Set Folder = FSO.GetFolder(PathToArc) '

FirstFile = True

For Each file In Folder.Files ' : - "Files",

maxdata = file.DateCreated '

If maxdata > Maximum Then

Maximum = maxdata

FirstFile = False

Else

End If

Next

theTime = DateDiff("h", Now, Maximum) * -1 '

If theTime > ArcHEvery Then '

NeedToBackup = True

ElseIf FirstFile = True Then

NeedToBackup = True

Else

End If

If NeedToBackup = True Then

'

if IsCompessing then

SafeCopyFile base, PathToArc '

 

set WshShell = WScript.CreateObject("WScript.Shell")

 

CommandLine = """C:Program FilesWinRARRar.exe"" a -ag -ibck -df -ri1:20 """ & PathToArc & "arc.rar"" """ & PathToArc & "1Cv8.1CD"""

'MsgBox CommandLine

 

Return = WshShell.Run(CommandLine) '

else

'

DstFileName = "" & PathToArc & "" & "arc" & FormatDateYYYYMMDDHHMMSS(Now) & ".rar"

'MsbBox "" & DstFileName

 

SafeCopyFile base, DstFileName '

 

End If

Else

End If

'

 

If FirstFile = False Then

 

Set FSO = CreateObject("Scripting.FileSystemObject")

Set Folder = FSO.GetFolder(PathToArc) '

For Each File In Folder.Files

nowday = DateSerial(Year(Now), Month(Now), Day(Now)) '

datafist = DateValue(File.DateCreated) '

If File.DateCreated < nowday Then '

For Each file1 In Folder.Files '

datatwo = DateValue(file1.DateCreated) '

If File.DateCreated <> file1.DateCreated Then

If datafist = datatwo Then

If File.DateCreated < file1.DateCreated Then ' ,

File.Delete

Exit For '

End If

Else

End If

Else

End If

Next

Else:

End If

Next

'

Set FSO = CreateObject("Scripting.FileSystemObject")

Set Folder = FSO.GetFolder(PathToArc) '

For Each File In Folder.Files

wik = 0 '

wikfist = DateValue(File.DateCreated) '

If wikfist <> nowday Then

For Each file1 In Folder.Files '

wiktwo = DateValue(file1.DateCreated) '

If wiktwo <> nowday Then

If wikfist < wiktwo Then

wik = wik + 1

If wik >= DaysForStore7 Then ' 7 ,

File.Delete

Exit For

Else

End If

Else

End If

Else

End If

Next

End If

 

Next

Else

End If

 

Sub SafeCopyFile(Src, Dst)

Set FSO = CreateObject("Scripting.FileSystemObject")

Set File = FSO.GetFile(Src)

Set TextStream = File.OpenAsTextStream(1)

FSO.CopyFile Src, Dst, 1 '

TextStream.Close

End Sub

 

 

 

Function FormatDateYYYYMMDD(D)

FormatDateYYYYMMDD = Year(D) & Format2DigitString(Month(D)) & Format2DigitString(Day(D))

 

End Function

 

Function FormatDateYYYYMMDDHHMMSS(D)

FormatDateYYYYMMDDHHMMSS = FormatDateYYYYMMDD(D) & Format2DigitString(Hour(D)) & Format2DigitString(Minute(D)) & Format2DigitString(Second(D))

 

End Function

 

Function Format2DigitString(N)

If N >= 10 Then

Format2DigitString= Format2DigitString & N

Else

Format2DigitString= Format2DigitString & "0" & N

End If

End Function