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

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

Ветеран


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

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


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

Const strDelimiter = " | "

Dim strSourceFile
Dim strDestinationFile

Dim strContent
Dim strNewContent
Dim objMatch


If WScript.Arguments.Count = 1 Then
	strSourceFile = WScript.Arguments.Item(0)
	
	With WScript.CreateObject("Scripting.FileSystemObject")
		If .FileExists(strSourceFile) Then
			strDestinationFile = .BuildPath(.GetParentFolderName(strSourceFile), .GetBaseName(strSourceFile) & "2." & .GetExtensionName(strSourceFile))
			
			With .OpenTextFile(strSourceFile)
				strContent = .ReadAll()
				.Close
			End With
			
			With WScript.CreateObject("VBScript.RegExp")
				.Pattern = _
					"File Name.type:  .*\.(.*)\r\n" & _
					"Resolution:  (.*)\r\n" & _
					"Duration:  (.*)\r\n" & _
					"Filesize:  (.*)\r\n"
				.Global = True
				.IgnoreCase = True
				.MultiLine = True
				
				If .Test(strContent) Then
					strNewContent = ""
					
					For Each objMatch In .Execute(strContent)
						With objMatch
							strNewContent = strNewContent & Trim(.Submatches(0)) & strDelimiter & Trim(.Submatches(2)) & strDelimiter & Trim(.Submatches(1)) & strDelimiter & Trim(.Submatches(3)) & vbCrLf
						End With
					Next
				End If
			End With
			
			With .CreateTextFile(strDestinationFile, True)
				.Write strNewContent
				.Close
			End With
		Else
			WScript.Echo "Can't find source file [" & strSourceFile & "]."
			WScript.Quit 2
		End If
	End With
Else
	WScript.Echo "Usage: cscript.exe //nologo """ & WScript.ScriptName & """ <Source file>"
	WScript.Quit 1
End If

WScript.Quit 0

Исходный файл указывается аргументом скрипта (также можно просто перетянуть исходный файл на скрипт в Проводнике).
Это сообщение посчитали полезным следующие участники:

Отправлено: 11:35, 15-02-2016 | #4