Rename all Files in the Directory
Here is the simple shell script to rename all files in the folder with increasing number.
In below example I am going to rename all jpg image with increasing number.
#!/bin/bash a=1 for i in *.jpg; do new=$(printf "%04d.jpg" "$a") mv -- "$i" "$new" let a=a+1 done
Output:
0001.jpg 0002.jpg 0003.jpg 0004.jpg 0005.jpg 0006.jpg 0007.jpg 0008.jpg 0009.jpg 0010.jpg
Few more Linux reference
https://github.com/roopendra/devops/tree/master/bash_scripting
(Visited 39 times, 1 visits today)