title: Multiple file rename in Android
body: <p>I'm trying to write a script using Android's shell to rename all files of a given extension to add the .bak extension, and another to remove it.</p>
  
  <p>This works for adding the .bak extension to all pdf files in the directory</p>
  
  <pre><code>ext=.bak
  for f in *.pdf
  do
    mv $f $f$ext
  done
  </code></pre>
  
  <p>But bash string slicing using <code>${varname:index:length}</code> doesn't work in the android shell, so I'm at a loss as to how to remove the extension. Does anyone have any ideas?</p>
  
  <p>EDIT: to clarify, I'm trying to find a way to delete the last four characters of a string in android shell. Other solutions that I have not considered which will solve my specific problem are also welcome.</p>
  
  <p>UPDATE:
  Based on the given answer, the following code will remove a file extension from any file possessing that extension in a current directory in an unmodified Android shell (where .bak can be replaced with the extension of your choice)</p>
  
  <pre><code>for f in *.bak
  do
      mv $f ${f%.*}
  done
  </code></pre>