title: renaming files with a shell script
body: <p>I have a lot of files following are the files</p>
  
  <pre><code>DSCN2352.JPG  DSCN2356.JPG  DSCN2360.JPG  DSCN2364.JPG
  DSCN2353.JPG  DSCN2357.JPG  DSCN2361.JPG  DSCN2365.JPG
  </code></pre>
  
  <p>I want to rename these files so I wrote a script </p>
  
  <pre><code>#!/bin/bash
  declare -a kl=( "$@" )
  kl=$(ls *.JPG)
  echo ${kl[@]}
  p=0
  for i in kl ;
   do mv $kl d$p.JPG
    $p=$p+1  ;
   done
  </code></pre>
  
  <p>I am getting error </p>
  
  <pre><code>mv: target `d0.JPG' is not a directory
  ./rename.sh: line 8: 0=0+1: command not found
  </code></pre>
  
  <p><strong>UPDATE</strong><br>
  after updating the script </p>
  
  <pre><code>#/bin/bash
  p=0
  for i in *.JPG;
  do
  mv "$i" "d$p.JPG"
  (( p+1 ))  ;
  done
  </code></pre>
  
  <p>files </p>
  
  <pre><code>DSCN2352.JPG  DSCN2356.JPG  DSCN2360.JPG  DSCN2364.JPG
  DSCN2353.JPG  DSCN2357.JPG  DSCN2361.JPG  DSCN2365.JPG
  </code></pre>
  
  <p>disappear and 
   I am left with only one file
  d0.jpg  rest of the files get deleted after executing updated script.</p>