写了个粗糙的- #ANSI编码&cls&powershell -Version 5.1 -NoLogo -NoProfile "gc '%~0'|out-string|iex"&pause&exit
- dir -Directory | %{
- $n = (dir ($_.Name + '.*'))[0]
- $f = gc -Encoding UTF8 $n | Out-String
- cd $_
- if ($f -match 'UniqueCode="(.*?)"') {
- ..\7za.exe a ..\tmp.zip ('-p' + $Matches[1]) * | Out-Null
- } else {
- ..\7za.exe a ..\tmp.zip * | Out-Null
- }
- cd ..
- $b = [System.Convert]::ToBase64String((gc .\tmp.zip -Encoding Byte -Raw))
- $utf8NoBom = New-Object System.Text.UTF8Encoding($false)
- [System.IO.File]::WriteAllText($n, ($f -replace 'Value=""', ('Value="{0}"' -f $b)), $utf8NoBom)
- rm .\tmp.zip
- }
复制代码
|