LoginSignup
2
3

More than 3 years have passed since last update.

PowerShellでファイル名を一気に変更する方法

Posted at

経緯

お客さんに提出するファイルを整理する際に、たくさんのファイル名の変更をする必要に迫られたため、「これPowerShellで簡単にできるんじゃね?」と考え調べてみた。

どうやればできた?

下記で一気に変更できた。

PowerShell
dir | rename-item -newname { $_.name -replace '古い文字列','新しい文字列' }

実行例

テスト用にテキストファイルを適当に5つ作成する。
フォルダ内のファイルすべての名前の頭に文字列"add"を追加する。

PowerShell
dir | rename-item -newname { $_.name -replace '^','add' }

所感

PowerShellを使うとごみプログラム作らなくても容易に、ファイル操作ができそう!

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3