title: How to add suffix to multiple files in subdirectories based on parent directory?
body: <p>I have 100+ directories as followed:</p>
  <pre><code>bins_copy]$ ls
  
  bin.1/  
  bin.112/  
  bin.126/  
  bin.24/  
  bin.38/  
  </code></pre>
  <p>etc. etc.</p>
  <p>Each of these directories contains two files names <code>genes.faa</code> and <code>genes.gff</code>, e.g. <code>bin.1/genes.faa</code></p>
  <p>I now want to add a suffix based on the parent directory so each gene file has a unique identifier, e.g. <code>bin.1/bin1_genes.faa</code> and <code>bin1_genes.gff</code>.</p>
  <p>I've been going down the google rabbit hole all morning and nothing has sufficiently worked so far.
  I tried something like this:</p>
  <pre><code>for each in ./bin.*/genes.faa ; mv genes.faa ${bin%-*}_genes.faa $each ; done 
  </code></pre>
  <p>but that (and several versions of it) gives me the following error:</p>
  <pre><code>-bash: syntax error near unexpected token `mv'
  </code></pre>
  <p>Since this is a really generic one I haven't figured it out yet and truly would appreciate your help with.</p>
  <p>Cheers/</p>