内部权力 我想使一组档案名称的变更过程自动化,并复制该目录上类似档案的最新版本。
删除
(file3.bak) --> none
更新目录中现有档案的名称
(file1.bak) --> (file2.bak) (file2.bak) --> (file3.bak)
另一名录的最新档案版本
(newestfile.txt) --> (file1.bak)
这是我ten忙:的:
$path = "c: emp"
cd $path
$count = (get-childitem $path -name).count
Write-Host "Number of Files: $count"
$items = Get-ChildItem | Sort Extension -desc | Rename-Item -NewName {"gapr.ear.rollback$count"}
$items | Sort Extension -desc | ForEach-Object -begin { $count= (get-childitem $path -name).count } -process { rename-item $_ -NewName "gappr.ear.rollback$count"; $count-- }