Thank you to both of you. I am going to test it it just that I just realized that my pdf files order is all wrong. The files order is like this when I run ls:
I think may be I can add "0" before the number part of the file names, so if the total of digit is only 1 add 2 more "0"s in front of it and add 1 more "0" if the total of digit is 2. Any better ideas on how shell script may help?
ARGV will have the values *.pdf i.e. a.pdf, b.pdf and c.pdf
so ARGV[1] is a.pdf, ARGV[2] is b.pdf and so on
this is what the code does
reads from the file "file1" # while ((getline < file1) > 0)
splits the ARGV into prefix and suffix and stores it in the array x. # split(ARGV[ ++c ], x, "."). c is incremented for the next value for next cycle. x will have x[1] => a and x[2] => pdf. As you can see, "." is used for splitting. Google awk split for more info.
Prints the mv command with old and new file name. Old file name is present in ARGV and new file name is formed from $1=>apple - which is read from the file, x[1]=>a, x[2]=>pdf
bash -v will execute the command whatever is given to it