有馬総一郎のブログ

(彼氏の事情)

2013年03月31日 10:45:00 JST - 1 minute read - Comments - PowerShell

ゼロ埋めした連番で名前変更したい

名前連番変更

有馬総一郎のブログ

Set-Location "E:\My Pictures\photo"
Get-ChildItem * -Include *.jpg | ForEach-Object { Rename-Item -Path $_.Name -NewName ("新しい名前" + (++$index).toString("000") + $_.Extension) }

有馬総一郎のブログ

有馬総一郎のブログ

これなら一行でいける。MS-DOSだとゼロ埋めがうまく行かなかったが、poweshellなら問題ない。

フォルダ移動すらめんどいなら、

Get-ChildItem "E:\My Pictures\photo - コピー" -Include *.jpg | ForEach-Object { Rename-Item -Path $_.FullName -NewName (($_.FullName -replace $_.Name, "") + "新しい名前" + (++$index).toString("000") + $_.Extension) }

ただ、これだとパスの中に変更前のファイル名と同じ部分があるとうまくいかない。連番開始を変えたければ$index = 開始番号と打ち込んでから、やる。

Tags: PowerShell

Subsonic 4.7はJava 1.7には対応してないようだ Subsonicのアップグレードのやり方

comments powered by Disqus