保存为ansi编码的bat
需要提取的字符串包含空字符(00H)时结果不准确- #?&cls&pause&powershell -c "type -literalpath '%~f0'|out-string|iex"&pause&exit
-
- #将 tone.cfg 改为 *.cfg 可批量处理
- $f=gci 'tone.cfg'
-
- $cd=[text.encoding]::GetEncoding('iso-8859-1')
- $f|%{
- $str=""
- $file=[io.fileinfo]$_
- $str=[io.file]::ReadAllText($file.fullname,$cd)
- $str=(($str -split '\u0000')|?{$_ -match '.wtg$'}) -join "`r`n"
- [io.file]::WriteAllBytes($file.directoryname+"\_new_"+$file.name,$cd.getbytes($str))
- [console]::writeline("has been save to file : "+$file.directoryname+"\_new_"+$file.name)
- }
复制代码
|