回复 8# hxc1995 - <# :
- cls&echo off&cd /d "%~dp0"&rem bat存为ANSI/GB2312编码
- path %SYSTEMROOT%\System32\WindowsPowerShell\v1.0;%path%
- set "current=%cd%"
- powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0'|Out-String|Invoke-Expression"
- pause
- exit
- #>
- $rp=@("张=陈","刘=王");
- $current=($env:current).trimend('\');
- $files=@(dir -literal $current -recurse|?{('.jpg' -eq $_.Extension) -and ($_ -is [System.IO.FileInfo])});
- for($i=0;$i -lt $files.length;$i++){
- $m=[regex]::match($files[$i].BaseName, '^[\u4e00-\u9fff]+');
- if($m.Success){
- for($j=0;$j -lt $rp.length;$j++){
- $kw=$rp[$j].split('=');
- if($m.groups[0].value -eq $kw[0]){
- $newname=$files[$i].BaseName.replace($kw[0], $kw[1])+$files[$i].Extension;
- $newfile=$files[$i].Directory.FullName.trimend('\')+'\'+$newname;
- write-host ($files[$i].FullName+' --> '+$newname);
- move-item -literal $files[$i].FullName $newfile -ErrorAction SilentlyContinue;
- break;
- }
- }
- }
- }
复制代码
|