Код:
Код: Выделить всё
function StrConvert($sSourceCharset, $sDestCharset) {
begin {
Set-Variable -Name adTypeText -Option Constant -Value 2
Set-Variable -Name adModeReadWrite -Option Constant -Value 3
$oStream = New-Object -ComObject "ADODB.Stream"
}
process {
$oStream.Type = $adTypeText
$oStream.Mode = $adModeReadWrite
$oStream.Open()
$oStream.Charset = $sSourceCharset
$oStream.WriteText($_)
$oStream.Position = 0
$oStream.Charset = $sDestCharset
$oStream.ReadText()
$oStream.Close()
}
}
$sPath = "E:\Песочница\0269"
Get-ChildItem -Path $sPath\*.* -Include *.txt |`
ForEach-Object -Process {
if((Get-Content -Path $_ | StrConvert "windows-1251" "cp866") -match "^Сумм:\d+(?:\.\d)?[^\d.]*$") {
$_ | Move-Item -Destination "E:\Песочница\0270"
}
}