本帖最后由 ivor 于 2018-12-30 17:13 编辑
| | | | | | | | | | | | | | | | | | | $path="C:\Users\mac\Desktop\新建文件夹 - 副本" | | | | $sapi = new-object -com sapi.spvoice | | dir -path "$path" | %{ | | if($_.Length -eq $null){ | | $parent = -Join($path,"\",$_) | | | | dir -path $parent -recurse | %{ | | if($_.Length -ne $null){ | | $Newfile = -Join($parent,"\",$_) | | $_.MoveTo($Newfile) | | if(!$?){ | | $Newfile = -Join($parent,"\",(Get-Random),"_",$_) | | write-host $_ | | $sapi.speak("文件名有重复") | | $_.MoveTo($Newfile) | | } | | } | | } | | | | } | | } | | $sapi.speak("文件复制结束") | | $dirs=$True | | while($dirs){ | | $dirs = Get-ChildItem "$path" -recurse | Where {$_.PSIsContainer -and @(Get-ChildItem -LiteralPath:$_.fullname).Count -eq 0} | | $dirs | remove-item -ErrorAction SilentlyContinue | | } | | $sapi.speak("空文件夹已删除") | | $sapi.speak("脚本运行结束")COPY |
2018年 特别友好版本,语音播报提示
修改10行的path为自己的路径 |