title: Add portion of filepath as a prefix to a filename for all files in a folder
body: <p>I'm trying to rename files based on the upstream directory name but I don't have any bash script experience. </p>
  
  <p>Let's say I have a directory that contains thousands of directories named "k99_xxx_properties", and in each k99 directory there is an Alignments directory, and in the Alignments directory there are files named sample1, sample2, sample3 in and so on. What I want to do is rename the sample files by adding the "k99_xxx" portion of the upstream directory as a prefix ("k99_xxx_sample1").</p>
  
  <p>I know all I need to do is loop through all k99_xxx_properties directories, save the k99_xxx portion of the directory name as a variable, and navigate into each k99_xxx, cd into Alignments, and loop through every file in Alignments to add k99_xxx as a prefix for the sample filenames.</p>
  
  <p>How would I go about that in a bash script?</p>