Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Ветеран


Сообщения: 27449
Благодарности: 8088

Профиль | Отправить PM | Цитировать


PAlkovnic, у Вас что — семинар?

Цитата PAlkovnic:
Имеются две папки: C:\Source »
Поправили по сравнению с прошлым вопросом, да ?


Код: Выделить весь код
Option Explicit

Dim strSourceFolder
Dim strDestFolder
Dim strDestPath


strSourceFolder = "C:\Source"
strDestFolder   = "C:\Dest"

With WScript.CreateObject("Scripting.FileSystemObject")
	If .FolderExists(strSourceFolder) Then
		If .FolderExists(strDestFolder) Then
			strDestPath = .BuildPath(strDestFolder, GetPrevDateToString())
			CreateFolderEx strDestPath
			
			If .GetFolder(strSourceFolder).SubFolders.Count > 0 Then
				.MoveFolder .BuildPath(strSourceFolder, "*.*"), strDestPath
			End If
			
			If .GetFolder(strSourceFolder).Files.Count > 0 Then
				.MoveFile   .BuildPath(strSourceFolder, "*.*"), strDestPath
			End If
		Else
			WScript.Echo "Can't find destination folder [" & strDestFolder & "]."
		End If
	Else
		WScript.Echo "Can't find source folder [" & strSourceFolder & "]."
	End If
End With

WScript.Quit 0
'=============================================================================

'=============================================================================
Function GetPrevDateToString()
	Dim dtDate
	
	dtDate = DateAdd("d", -1, Date())
	
	GetPrevDateToString = Right("0000" & CStr(Year(dtDate)), 4) & Right("00" & CStr(Month(dtDate)), 2) & Right("00" & CStr(Day(dtDate)), 2)
End Function
'=============================================================================

'=============================================================================
Sub CreateFolderEx(strPath)
	With WScript.CreateObject("Scripting.FileSystemObject")
		If Not .FolderExists(strPath) Then
			CreateFolderEx .GetParentFolderName(strPath)
			.CreateFolder strPath
		End If
	End With
End Sub
'=============================================================================
Это сообщение посчитали полезным следующие участники:

Отправлено: 13:36, 20-06-2013 | #2