Saori Yoshimoto work notes since 2018

Thursday, November 29, 2018

[script-shell] Renaming files to sequential numbers

It works for based on Bash(Linux).
ex). execution method
1(file name): test_rename.sh
2(exetcute ): ./test_rename.sh  
-------------- 
i=1

for f in $(ls -1 *.jpg | sort -t '.' -k2h)
do
 mv "$f" $(printf "001_guide.%04d.jpg" $i)
 : $((i++))
done