title: bash script to append word to filenames
body: <p>I'm trying append to word "dicom" to the front of many filenames in a set of folders. The folders all begin with "s" (referred to by "s*" in the script below), and each contain many files (specified by "*" below)--I'd like all of these files to be changed using this bash script. I tried to run this: </p>
  
  <pre><code>for file in /Volumes/USB_AIB/DICOMFunCurrentBatch/MOVr1unzip/s*/*
    do
    mv $file dicom${file%%}
  done
  </code></pre>
  
  <p>but got thousands of lines of the following error (once for each file within each folder--this is just an example of one of them):</p>
  
  <pre><code>mv: rename /Volumes/USB_AIB/DICOMFunCurrentBatch/MOVr1unzip/s307_1/29217684 to dicom/Volumes/USB_AIB/DICOMFunCurrentBatch/MOVr1unzip/s307_1/29217684: No such file or directory
  </code></pre>
  
  <p>Any ideas on how to fix it?</p>