本帖最后由 flashercs 于 2019-11-21 12:50 编辑
当前目录和子目录- <#*,:&cls
- @echo off
- pushd "%~dp0"
- Powershell -NoProfile -ExecutionPolicy RemoteSigned -Command ". ([ScriptBlock]::Create((Get-Content -LiteralPath \"%~0\" -ReadCount 0 | Out-String ))) "
- popd
- pause
- exit /b
- #>
- Get-ChildItem -Recurse -Force | Where-Object { -not $_.PSIsContainer } | Sort-Object -Descending -Property CreationTime |`
- Group-Object -Property PSChildName | ForEach-Object {
- for ($i = 1; $i -lt $_.Count; $i++) {
- Remove-Item -LiteralPath $_.Group[$i].PSPath -Force -Verbose
- }
- }
复制代码
|