WSH
[spoiler]Код: [/spoiler]
Код: Выделить всё
Option Explicit
Dim strSourceFile
Dim strDestFile
Dim objFSO
Dim objRegExp
Dim arrContent
Dim strLine
Dim strResultLine
strSourceFile = "C:\Мои проекты\0202\cords.xml"
strDestFile = "C:\Мои проекты\0202\Result.txt"
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strSourceFile) Then
With objFSO.OpenTextFile(strSourceFile)
arrContent = Split(.ReadAll(), vbCrLf)
.Close
End With
Set objRegExp = WScript.CreateObject("VBScript.RegExp")
With objRegExp
.Pattern = "^$"
.IgnoreCase = True
End With
With objFSO.CreateTextFile(strDestFile, True)
For Each strLine In arrContent
If objRegExp.Test(strLine) Then
With objRegExp.Execute(strLine).Item(0).Submatches
strResultLine = _
.Item(0) & " = " & _
.Item(1) & ", " & _
.Item(2) & ", " & _
CStr(CLng(.Item(1)) + CLng(.Item(3))) & ", " & _
CStr(CLng(.Item(2)) + CLng(.Item(4)))
End With
.WriteLine strResultLine
Else
WScript.Echo "Can't parse string [" & strLine & "]."
End If
Next
.Close
End With
Set objRegExp = Nothing
Else
WScript.Echo "Can't find source file [" & strSourceFile & "]."
WScript.Quit 2
End If
Set objFSO = Nothing
WScript.Quit 0Пакетный файл
[spoiler]Код: [/spoiler]
Код: Выделить всё
@echo off
setlocal enableextensions enabledelayedexpansion
set sSourceFile=C:\Мои проекты\0202\cords.xml
set sDestFile=C:\Мои проекты\0202\Result2.txt
if exist "%sSourceFile%" (
>"%sDestFile%" (
for /f usebackq^ tokens^=2^,4^,6^,8^,10^ delims^=^" %%i in ("%sSourceFile%") do (
set id=%%~i
set /a x = %%~j
set /a y = %%~k
set /a w = %%~l
set /a h = %%~m
set /a xw = !x! + !w!
set /a yh = !y! + !h!
echo !id! = !x!, !y!, !xw!, !yh!
)
)
) else (
echo Can't find source file [%sSourceFile%].
exit /b 1
)
endlocal
exit /b 0
. Вы сам файл видели?
.