Linux ファイル名を一括で変更する
Linuxで、ファイル名を一括で変更する手順を記述してます。
環境
- OS Rocky Linux release 8.4 (Green Obsidian)
- shell: /bin/bash
ファイル名を一括で変更
ファイル名を一括で変更する場合は、「rename」コマンドを使用します。
実際に、テスト用のファイルを作成して実行してみます。
まずは、テスト用のファイルを作成します。
touch hoge_{1..5}.txt
ファイルが作成されたことが確認できます。
ls
<出力結果>
hoge_1.txt hoge_2.txt hoge_3.txt hoge_4.txt hoge_5.txt
この「hoge_(1~5).txt」の「hoge」の部分を、「foo」に一括でリネームします。
rename hoge foo *.txt
一括で「foo」にリネームされたことが確認できます。
ls
<出力結果>
foo_1.txt foo_2.txt foo_3.txt foo_4.txt foo_5.txt
-
前の記事
php strtoupperで文字列を大文字に変換する 2021.11.19
-
次の記事
python PySimpleGUIでButtonのイベントを設定する 2021.11.19
コメントを書く