1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Powershell] ファイル名を一括変更

Posted at

やりたいこと

フォルダ内のファイル名をあるパターンで一括変更したい
いつも何だったけ?となるのでメモ

使うコマンドレット

コマンドレット 何をする
Get-ChildItem フォルダ内のオブジェクトを取得する
Rename-Item オブジェクトの名前を変更する

サンプル

あるフォルダの中にファイル名の一部が20200630になっているものがあるとする
これを一括で202008に変更したい場合

Set-Location 'C:\Users\xxxxxxxx'
Get-ChildItem | Rename-Item -NewName {$_.Name -replace '20200630','202008'}

Get-ChildItemで取得したファイル名をパイプでRename-Itemに渡すと{$_.Name -replace '置換前', '置換後'}でぐるぐるループしてファイル名を変更してくれる

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?