Увеличение имени файла скрипта Powershell
В Powershell я хочу автоматизировать процесс изменения имени файла группы файлов и скопировать последнюю версию аналогичного файла в этот каталог.
Delete oldest
<code>(file3.bak) --> none </code>
Increase filename of current files in backup directory
<code> (file1.bak) --> (file2.bak) (file2.bak) --> (file3.bak) </code>
Copy latest version of file from another directory to this backup directory
<code>(newestfile.txt) --> (file1.bak) </code>
Это насколько я получил и застрял:
<code>$path = "c:\temp" 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-- } </code>