27
23

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 1 year has passed since last update.

PowerShellでファイル名一括置換

Last updated at Posted at 2018-08-21

基本的な使い方

ls | Rename-Item -NewName { $_.Name -replace '置換対象文字列','置換後文字列'}

> ls

HOGE1.txt
HOGE2.txt
HOGE3.txt

とあった場合、HOGEをFUGAにしたいときは下記のようにする。

> ls | Rename-Item -NewName { $_.Name -replace 'HOGE(.*)','FUGA$1'}

FUGA1.txt
FUGA2.txt
FUGA3.txt

ファイル名にカッコが含まれる場合、「\」でエスケープ。

HOGE1(12345).txt
HOGE2(23456).txt
HOGE3(34567).txt
> ls | Rename-Item -NewName { $_.Name -replace '\(.*\)',''}

HOGE1.txt
HOGE2.txt
HOGE3.txt
27
23
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
27
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?