title: Bash script to change file names recursively
body: <p>I have a script for changing file names of mht files but it does not traverse through dirs and sub dirs. I asked a question on a local forum and I got an answer that this is a solution:</p>
  
  <pre><code>find . -type f -name "*.mhtml" -o  -type f -name "*.mht" | xargs -I item sh -c '{ echo item; echo item | sed "s/[:?|]//g"; }' | xargs -n2 mv
  </code></pre>
  
  <p>But it generates an error. With some of my experimenting it turns out that <code>sh -c</code> breaks file names with space and that this generates an error. How can I fix this?</p>
  
  <pre><code>#!/bin/bash
  # renames.sh
  # basic file renamer
  for i in  . *.mht
  do
  j=`echo $i | sed 's/|/ /g' | sed 's/:/ /g' | sed 's/?//g' | sed 's/"//g'`
      mv "$i" "$j"
      done
  </code></pre>