🦍
PowerShellのコマンドメモ
_01, _02...の数字を逆順にしたい
該当ファイルのあるディレクトリに移動してから行う。
1. 数字を逆順にして_tmpをつける
for ($i = 1; $i -le {ファイル数}; $i++) {
$oldMonth = "{0:D2}" -f $i
$newMonth = "{0:D2}" -f ({ファイル数 + 1} - $i)
Rename-Item "fileName_$oldMonth.html" "fileName_${newMonth}_tmp.html"
}
2. _tmpをとる
Get-ChildItem -Filter "*_tmp.mdx" | ForEach-Object {
$newName = $_.Name -replace "_tmp", ""
Rename-Item $_.FullName $newName
}
Discussion