|
#PowerShell后缀名是ps1
#$file.fullname
#$file.name
#代码开始
$hzm="bmp" #后缀名
$files = Get-Childitem -Recurse -Include *.$hzm #遍历bmp
foreach ($file in $files) #遍历文件
{
$str = $file.name -replace("\.$hzm","") #获取bmp的名字
$ustr = ""
for($i = 0; $i -lt $str.Length; $i++){
if([int]$str[$i] -gt 32 -and [int]$str[$i] -lt 127){
$ustr += $str[$i]
}
else{
$ustr += [System.String]::Format("\u{0:x4}", [int]$str[$i])
}
}
$ustr= $ustr -replace("\\","") #删除unicode里的\符号
Rename-Item $file.pspath -NewName $ustr".$hzm" #替换文件名
$ustr
}
Start-Sleep -Milliseconds 6000 #等待6秒退出
#代码结束
|
|