1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windowsでのファイル名一括変換

Posted at

環境

  • Windows 10
  • PowerShell利用可能
  • プログラムの実行権限なし
  • インストール権限なし

やりたいこと

100個あるディレクトリの名前を以下のように変更したい

before
01_hogehoge/
02_hogehoge/
︙
99_hogee/
test.txt
text.xlsx
after
001_hogehoge/
002_hogehoge/
︙
099_hogee/
test.txt
text.xlsx

やり方

PowerShellで以下のコマンドを当該ディレクトリのある階層に移動して実行する

コード例
Get-ChildItem | ? { $_.Name -match "^[0-9]+.+" } | ? { $_.PSIsContainer } | Rename-Item -NewName { $_.Name -replace "^([0-9]+).*", "0$_" }

おそらくもっと簡単にかけると思うが、とりあえず動いたからヨシ!

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?