Facebooktwittergoogle_plusredditpinterestlinkedinmail

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
Rename all Files in the Directory Roopendra LinuxScripting,
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
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. <pre>#!/bin/bash a=1 for i in *.jpg; do new=$(printf "%04d.jpg" "$a") mv -- "$i" "$new" let a=a+1 done</pre> <strong>Output:</strong> <pre>0001.jpg 0002.jpg 0003.jpg 0004.jpg 0005.jpg 0006.jpg 0007.jpg 0008.jpg 0009.jpg 0010.jpg </pre>
(Visited 78 times, 6 visits today)
Facebooktwittergoogle_pluslinkedinrss