LoginSignup
0

posted at

renameコマンド使ってみた

renameコマンドで個人的に使った条件を備忘録的に置いておきます。(随時更新するかも)

install

brew install rename

使ったケース

ディレクトリ内のファイルの名前を特定の名前blogpost.mdに一括でリネームしたい

.
├── A
│   └── aaa
│       └── aaa.md
├── B
│   └── bbb
│       └── bbb.md

.
├── A
│   └── aaa
│       └── blogpost.md
├── B
│   └── bbb
│       └── blogpost.md

にしたい

答え

rename 's/(.+)\/(.+)(\.md+$)/$1\/blogpost.md/' ./**/*.md

$1がディレクトリ名部分、$2が変える前のファイル名、$3が拡張子になる

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
What you can do with signing up
0