I'm merging two datasets, and they're in the format 40000X-????.mrc
. However, they both start with 0000
. Therefore, I want to start the second dataset after the end of the first (if the first dataset has 12 files, then I want the second dataset to start with 40000X-0013.mrc
, and so on).
I found some partial answers online, so my code is as follows:
#!/usr/bin/env bash
c=12
for f in *.mrc ; do
mv -v "$f" "40000X-$(printf '%0*d' 4 $c).mrc"
let c=c+1
done
Expected outcome: Renames all files in order, starting from 12, continuing until it has processed all the files.
Actual outcome: Due to -v
option it actually claims to have renamed all of the files, but on inspection of the directory, only the last 12 seem to remain. From testing, this is dependent on the start index c
, and if I change it, it can indeed iterate through more, but it messes up the starting index.
Any help with this is appreciated.