[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sequential files

From: MN
Subject: Re: Sequential files
Date: Mon, 29 Nov 2021 20:03:27 +0100

On 21-11-28 00:01:11, Daniel Mills wrote:
>    You can 0-pad numbers with printf, -v is nice for storing the result in a
>    variable. For example,
>    pad_width=2
>    printf -v outfile "%s_%0*d.%s" "${1%.*}" "$pad_width" "$((counter++))"
>    "${1##*.}"
>    mv -i ./"$1" "$outfile"

Thank you for your answer.
Is it possible, or easy to dynamically change the pad_width and 
rename the already renamed files?
The hundredth example.ext turns into example_100.ext and all the 
previous files have one digit less. (example_99.ext for instance)

If it's not possible, or not easily possible, then I'll use a higher 
value of pad_width, just to be on the safe side.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]