PowerShell获得饥荒游戏Mods中文件夹对应的Mod名
放入mods中执行即可[code]# Code by 老刘# 支持中文、Byte串起的UTF-8、双引号包裹、单引号包裹
# 有bug请联系QQ:632171029
$RegEx = [regex]"\s*\bname\b\s*=\s*([""'])(.*?)\1" # 匹配name
$RegEx2 = [regex]"(?:\\\d{1,3})+"
Cls
Dir | Where-Object{$_ -Is [System.IO.DirectoryInfo]} | ForEach-Object {
$_.GetFiles("modinfo.lua") | ForEach-Object{
Write-Host -Object $_.Directory.Name -Foreground "Yellow" -NoNewline
Write-Host "`t" -NoNewline
$oText = $_.OpenText()
$Name = $RegEx.Match($oText.ReadToEnd()).Groups[2].Value
$oText.Close()
$oUTF8String = $RegEx2.Match($Name)
If($oUTF8String.Success){
$Name = $RegEx2.Replace($Name,[System.Text.Encoding]::UTF8.GetString($oUTF8String.Value.Split("\")))
}
Echo $Name
}
}
Pause[/code]
页:
[1]