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

More than 1 year has passed since last update.

awkコマンドで簡単にjpgファイルを一括で連番でリネーム

Posted at

概要

jpgを一括で連番でリネームする想定で記載します。

背景

ファイル名一括変更のアプリなどダウンロードして使えますが、エンジニアなのでコマンドなどでできるとスマートですよね。

以下で出来ます。

事前に

cd {作業フォルダ}

でファイルがあるフォルダに移動しておいてください。

また、そのフォルダにリネーム対象のファイルを置いて、かつ、それ以外のファイルは置かないようにしてください。

作業

対象ファイル確認

以下のコマンドで、対象のファイルを、そのファイルがどの名前にリネームされるか確認できます。

ls | awk '{ printf "mv %s %02d.jpg\n", $0, NR }'

リネーム実行

問題なければ以下のコマンドでリネームしてください。

ls | awk '{ printf "mv %s %02d.jpg\n", $0, NR }' | sh

うん、簡単!

その他

ファイル名に全角括弧があると実行エラーになる可能性あります

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