測試環境:WIN10,儲存為bat.
第9行設定檔案路徑,輸出結果為 "原檔名.log".
@echo off&cd/d "%~dp0"
more +8 "%~f0" >"%temp%\%~n0.ps1"
powershell -NoLogo -NoProfile -ExecutionPolicy bypass -File "%temp%\%~n0.ps1"
del /f /q "%temp%\%~n0.ps1"
pause
#>
$file="a.txt";#檔案路徑
$content=type $file -ReadCount 0
[system.collections.arraylist] $result=@();
foreach($line in $content)
{
if($line -match ".*
}
set-content "$($file).log" $result;#輸出結果
測試環境:WIN10,儲存為bat.
第9行設定檔案路徑,輸出結果為 "原檔名.log".
@echo off&cd/d "%~dp0"
more +8 "%~f0" >"%temp%\%~n0.ps1"
powershell -NoLogo -NoProfile -ExecutionPolicy bypass -File "%temp%\%~n0.ps1"
del /f /q "%temp%\%~n0.ps1"
pause
#>
$file="a.txt";#檔案路徑
$content=type $file -ReadCount 0
[system.collections.arraylist] $result=@();
foreach($line in $content)
{
if($line -match ".*
.*"){[void] $result.Add($Matches[1]);}}
set-content "$($file).log" $result;#輸出結果