保存为ansi编码的bat
txt文件编码需要为utf8
不成对引号的不替换
英文引号不分左右,结果可能不准确- #?&cls&pause&powershell -c "type -literalpath '%~f0'|out-string|iex"&pause&exit
-
- $cd='utf8'
-
- $z={param($s) '“'+$s.value.substring(1,$s.value.length-2)+'”'}
- $zz={param($s) "‘"+$s.value.substring(1,$s.value.length-2)+"’"}
-
- gci -n|%{
- $str=[io.file]::ReadAllText($pwd.path+"\"+$_)
- $str=[regex]::Replace($str,'".*?"',$z)
- $str=[regex]::Replace($str,"'.*?'",$zz)
- sc -LiteralPath ("__new"+$_) -Encoding $cd -value $str
- [console]::writeline("has been save to file: "+"__new"+$_)
- $str=""
- }
复制代码
|