Volniy

|
Posted: Wed Jan 27, 2010 02:25 Post subject: |
|
|
Bubek wrote: | как бы сделать так, чтобы при наличии файла с создаваемым именем создавался файл 2010.01.25_2_файл1.zip, а если есть и такой, то 2010.01.25_3_файл1.zip и так далее. |
Code: | ' Copyright (c) 2010, Volniy
Option Explicit
Dim FSO, StreamFile, theFile
Dim M,D, sDate, Cnt : Cnt = 2
Set FSO = CreateObject("Scripting.FileSystemObject")
Set StreamFile = FSO.OpenTextFile(WScript.Arguments(0), 1)
Do While Not StreamFile.AtEndOfStream
Set theFile = FSO.GetFile(StreamFile.ReadLine)
M=Month(Date): If M<10 Then M= "0" & M
D=Day(Date): If D<10 Then D= "0" & D
sDate = Year(Date) & "." & M & "." & D &"_"
If FSO.FileExists(FSO.BuildPath(theFile.ParentFolder, sDate & theFile.Name)) Then
Do While FSO.FileExists(FSO.BuildPath(theFile.ParentFolder, sDate & CStr(Cnt) _
& "_" & theFile.Name)) = True
Cnt = Cnt + 1
Loop
theFile.Name = sDate & CStr(Cnt) & "_" & theFile.Name
Else
theFile.Name = sDate & theFile.Name
End If
Loop
Set theFile = Nothing
Set StreamFile = Nothing
Set FSO = Nothing
WScript.Quit()
|
|
|