title: Shell script: execute cmd on a file, with additional processing of file name
body: <p>So I am going to post a question about shell scripting again.</p>
  
  <p><strong>Problem Definition:</strong>    For all files under a dir, ex.:</p>
  
  <ul>
  <li>A_anything.txt, B_anything.txt, ......</li>
  </ul>
  
  <p>I want to execute a script, say 'CMD', on each of them, with the output files named like:</p>
  
  <ul>
  <li>A_result.txt, B_result.txt, ......</li>
  </ul>
  
  <p>In addition, at the <strong>first line</strong> of these output file, I want to have the <strong>file name</strong> of the original one. </p>
  
  <p>The 'find -exec' util seems to me unable to extract part of the file name. </p>
  
  <p>Does someone know a solution to this problem, by any means(shell, python, find,etc)? Thank you!</p>