[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Sequential files
From: |
MN |
Subject: |
Re: Sequential files |
Date: |
Sat, 27 Nov 2021 23:46:29 +0100 |
Alright,
Since I got no replies, I guess this is how it is to be done.
I changed my mind about counter=0 and I'm using counter=1 now.
I was wondering if I could zero pad the files?
If there are less than 9 files then I wouldn't change anything, but
when I reach example_10.png, I would rename the first 9 files to
example_01.png, example 02.png and so forth.
And I would do the same thing with hundred and thousand.
example_001.png and example_0001.png
On 21-11-24 12:08:52, MN wrote:
> Hello,
> I wrote a script, which works, but I'd like you to review it.
> Programs that I use don't offer sequential file savings.
> My script waits for them and numbers them in sequence one by one.
>
> First, I have to save the file.
> If the first file is 'example.png', then I run my script like that ./myscript
> example.png
>
> From now on I don't have to worry about the name of the files,
> I can save them under the very same name.
>
> Actual script:
>
> #!/bin/bash
> counter=0
> while true; do
> until [[ -e "$1" ]] ; do
> sleep 1
> done
> mv -i ./"$1" "${1%.*}_$((counter++))".${1##*.}
> done
>
>
> How could this be improved?
- Re: Sequential files,
MN <=