标题: [原创代码] PowerShell获得饥荒游戏Mods中文件夹对应的Mod名 [打印本页]
作者: 老刘1号 时间: 2019-4-12 22:59 标题: PowerShell获得饥荒游戏Mods中文件夹对应的Mod名
放入mods中执行即可- # 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
复制代码
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |