Total Commander Forum Index Total Commander
Форум поддержки пользователей Total Commander
Сайты: Все о Total Commander | Totalcmd.net | Ghisler.com | RU.TCKB
 
 RulesRules   SearchSearch   FAQFAQ   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Single Post  Topic: Script Request 
Author Message
Volniy



PostPosted: Wed Jan 27, 2010 02:25    Post subject: Reply with quote

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()
View user's profile Send private message


Powered by phpBB © 2001, 2005 phpBB Group