A shell script for Renaming large number of files in Linux
Hi, today I'm going to Blog about a very simple shell script, that may help you guys a lot.NO big deal, its very simple one. It was very helpful to me, once I had to rename a large number of images of Kim Kardashian. So then I realise it will very easy doing it with a Shell script rather than manually rename it. #!/bin/bash # # Author: Gihan De Silva @ gihansblog.com # rename script # rename.sh clear x=0 for i in `ls *.jpg` do x=`expr $x + 1` mv $i Kim_Kardashian$x.jpg done echo "rename done!" Code Explanation! #!/bin/bash This is how always a shell script starts. clear This line clears all the things already in the terminal window. x=0 This line define and declare a variable. for i in `ls *.jpg` This line starts a loop and, it will list down all the JPEG(jpg) type images. x=`expr $x + 1` This line increases the value of x by 1 . mv $i Kim_Kardashian$x.jpg This line renames all the files according to a sequence like, Kim_Kardashian1.jpg , Kim_Kardashian2.jpg, Kim_Kard...