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?

【備忘録】フォルダの中のファイルに名前順にして連番の名前をつける

Posted at

名前の一括変更を行いたいフォルダまで移動し、以下のコードをターミナルで実行する。

i=1
for f in *; do
  if [[ -f "$f" ]]; then  # ファイルのみ処理(フォルダは無視)
    mv "$f" "${i}_$f"
    ((i++))
  fi
done

実行例

元のファイル

Take 2025-02-21 04.05.32 PM.csv
Another File.csv
Sample-Data 01.csv

実行後

1_Take 2025-02-21 04.05.32 PM.csv
2_Another File.csv
3_Sample-Data 01.csv
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?