本帖最后由 flashercs 于 2019-1-31 19:42 编辑
加个进度看看吧,不知处理到哪里了。- @echo off
- REM UTF8编码,过滤控制字符和UTF8不能识别的字符后,选择字符串作为文件名并重命名文件。
- set "dir=%~dp0."
- powershell -Command "foreach ($item in (Get-ChildItem -LiteralPath \"%dir%\" -Filter *.* -File)) { if ([System.IO.File]::ReadAllText($item.FullName, [System.Text.Encoding]::UTF8) -match '(?<=model_name[\x00-\x1F\uFFFD]+)[^\x00-\x1F\uFFFD]+(?=[\x00-\x1F\uFFFD]*disp_outl_info)') { $baseName = $Matches[0] + $item.Extension; $i = 0; $newName = $baseName; while (Test-Path -LiteralPath (Join-Path -Path $item.DirectoryName -ChildPath $newName)) { $newName = $baseName + '.' + (++$i);} Write-Host 'Renaming file ' -NoNewline; Write-Host $item.FullName -NoNewline -ForegroundColor Green; Write-Host ' to ' -NoNewline; Write-Host $newName -ForegroundColor Green; Rename-Item -LiteralPath $item.FullName -NewName $newName; }}"
- pause
- exit /b
复制代码
|