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.

【メモ】bashで任意のファイル名を連番に変換

Last updated at Posted at 2019-08-21

bashで任意のファイル名を連番に変換

jpegファイルからffmpegを用いてavi,mpg等を作成するためには、欠番のない 1 から始まる連番のファイル名である必要がある。

複数個ある

X*.jpeg (*は任意)

という一連のファイルを

X0001.jpeg
X0002.jpeg
...

という連番のファイル名に変更したい場合、以下のようなスクリプトで解決できる。


#!/bin/bash
a=0
for i in X*.jpeg; do
let a="${a}+1"
s=$(printf "X%04d.jpeg" $a)
echo $s
cp $i $s
done
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?