text: user-1: I am completely new to bioinformatics so I'm looking to learn how to do this.
  I have multiple directories with fastq files: E.g; 10 Directories with each time series, each with Treatment and control directories, each with rep1 rep2 rep3.
  For example: T9/Infected/Rep1/*.fastq.gz.
  I'm looking to create a loop to run fastQC on each fastq file instead of having to submit a separate job for each directory.
  Then to either output the fastQC data to a single directory or if possible a directory corresponding to each rep - e.g. rep1 results go into a folder called rep1 and so on.
  
  user-1: Example dir structure:
  $ find FastQC/
  FastQC/
  FastQC/T9
  FastQC/T9/Infected
  FastQC/T9/Infected/Rep1
  FastQC/T9/Infected/Rep1/test11.fastq.gz
  FastQC/T9/Infected/Rep1/test1.fastq.gz
  FastQC/T9/Infected/Rep2
  FastQC/T9/Infected/Rep2/test2.fastq.gz
  FastQC/T9/Infected/Rep3
  FastQC/T9/Infected/Rep3/test3.fastq.gz
  
  If understood well You need to run some job on every *.fastq.gz file. Then You can do something like this (my example job is gzip test, replace with your job):
  Rookie:
  $ find FastQC/ -type f -name "*.fastq.gz" | xargs gzip -tv
  FastQC/T9/Infected/Rep1/test11.fastq.gz:         OK
  FastQC/T9/Infected/Rep1/test1.fastq.gz:  OK
  FastQC/T9/Infected/Rep2/test2.fastq.gz:  OK
  FastQC/T9/Infected/Rep3/test3.fastq.gz:  OK
  
  Solid:
  $ find FastQC/ -type f -name "*.fastq.gz" -print0 | xargs -0 -I {} gzip -tv {}
  FastQC/T9/Infected/Rep1/test11.fastq.gz:         OK
  FastQC/T9/Infected/Rep1/test1.fastq.gz:  OK
  FastQC/T9/Infected/Rep2/test2.fastq.gz:  OK
  FastQC/T9/Infected/Rep3/test3.fastq.gz:  OK
  
  
  find finds files with name *.fastq.gz and outputs it with zero byte delimited (to support weird characters like space etc. in filenames)
  xargs represents output as {} and passes it to gzip -tv
  
  
  If You want to copy files inside one heap folder:
  $ find FastQC/ -type f -name "*.fastq.gz" -print0 | xargs -0 -I {} cp -pv {} FastQC_heap/
  `FastQC/T9/Infected/Rep1/test11.fastq.gz' -> `FastQC_heap/test11.fastq.gz'
  `FastQC/T9/Infected/Rep1/test1.fastq.gz' -> `FastQC_heap/test1.fastq.gz'
  `FastQC/T9/Infected/Rep2/test2.fastq.gz' -> `FastQC_heap/test2.fastq.gz'
  `FastQC/T9/Infected/Rep3/test3.fastq.gz' -> `FastQC_heap/test3.fastq.gz'
  
  
  user292: This is the typical kind of job for snakemake.
  Assuming your have one file per replicate named for instance T9/Infected/Rep1/Rep1.fastq.gz, you can prepare a file that you call Snakefile with the following content:
  timepoints = list(range(10))
  conditions = ["control", "infected"]
  replicates = [1, 2, 3]
  
  rule all:
      input:
          expand(
              "T{time}/{cond}/Rep{rep}/Rep{rep}_fastqc.html",
              time=timepoints,
              cond=conditions,
              rep=replicates)
  
  rule do_fastqc:
      input:
          fastq = "T{time}/{cond}/Rep{rep}/Rep{rep}.fastq.gz"
      output:
          html = "T{time}/{cond}/Rep{rep}/Rep{rep}_fastqc.html"
      shell:
          """
          fastqc {input.fastq}
          """
  
  Put this file in the directory that contains the T* directories and run snakemake from there.
  The top all rule explains which files you want. The do_fastqc rule explains how to make one fastqc report from one fastq.gz file.
  With a bit more work, this can be used to submit jobs to a computing cluster. Snakemake has some tools for this.
  If you don't know the exact names of the fastq files but they all follow the same pattern, you will need to use the glob python module and do a little bit of programming to determine the possible values for rep, cond and time. The "snakefile" can contain any python code you want.
  If there are no regular pattern in the file names, fix this issue first ;)
  
  user2085: multiqc kind of glazes over some important information, like the exact adapters and duplicated sequences in a library. If you plan to spend big $$ for sequencing a library it is better to look at both the multiqc report and the actual fastqc html report to get a better idea of any error modes. 
  Going off of @Kubator's answer, I noticed that there was no command to run fastqc.
  Here's a simple one-liner to run fastqc in parallel on all of your fastq files. The -j 25 uses 25 threads. Change 25 to however many threads you want/have for max speed.
  #Run fastqc on everything in parallel.
  > find ../reads/ -name '*.fastq.gz' | awk '{printf("fastqc \"%s\"\n", $0)}' | parallel -j 25 --verbose
  # copies all the fastqc files to directory ./    
  > find ../reads/ -name '*fastqc.*' | xargs -I '{}' mv '{}' ./
  
  These files might be output by multiqc, anyway!
  edit - now the command is safe for whitespace in file names. Please, no newlines in filenames though!
  
original_text: -1: <p>I am completely new to bioinformatics so I'm looking to learn how to do this.</p>
  
  <p>I have multiple directories with fastq files: E.g; 10 Directories with each time series, each with Treatment and control directories, each with rep1 rep2 rep3.</p>
  
  <p>For example: T9/Infected/Rep1/*.fastq.gz.</p>
  
  <p>I'm looking to create a loop to run fastQC on each fastq file instead of having to submit a separate job for each directory.</p>
  
  <p>Then to either output the fastQC data to a single directory or if possible a directory corresponding to each rep - e.g. rep1 results go into a folder called rep1 and so on.</p>
   -1: <p>Example dir structure:</p>
  
  <pre><code>$ find FastQC/
  FastQC/
  FastQC/T9
  FastQC/T9/Infected
  FastQC/T9/Infected/Rep1
  FastQC/T9/Infected/Rep1/test11.fastq.gz
  FastQC/T9/Infected/Rep1/test1.fastq.gz
  FastQC/T9/Infected/Rep2
  FastQC/T9/Infected/Rep2/test2.fastq.gz
  FastQC/T9/Infected/Rep3
  FastQC/T9/Infected/Rep3/test3.fastq.gz
  </code></pre>
  
  <p>If understood well You need to run some job on every *.fastq.gz file. Then You can do something like this (my example job is <strong>gzip test</strong>, replace with your job):</p>
  
  <p>Rookie:</p>
  
  <pre><code>$ find FastQC/ -type f -name "*.fastq.gz" | xargs gzip -tv
  FastQC/T9/Infected/Rep1/test11.fastq.gz:         OK
  FastQC/T9/Infected/Rep1/test1.fastq.gz:  OK
  FastQC/T9/Infected/Rep2/test2.fastq.gz:  OK
  FastQC/T9/Infected/Rep3/test3.fastq.gz:  OK
  </code></pre>
  
  <p>Solid:</p>
  
  <pre><code>$ find FastQC/ -type f -name "*.fastq.gz" -print0 | xargs -0 -I {} gzip -tv {}
  FastQC/T9/Infected/Rep1/test11.fastq.gz:         OK
  FastQC/T9/Infected/Rep1/test1.fastq.gz:  OK
  FastQC/T9/Infected/Rep2/test2.fastq.gz:  OK
  FastQC/T9/Infected/Rep3/test3.fastq.gz:  OK
  </code></pre>
  
  <ol>
  <li>find finds files with name *.fastq.gz and outputs it with zero byte delimited (to support weird characters like space etc. in filenames)</li>
  <li>xargs represents output as {} and passes it to gzip -tv</li>
  </ol>
  
  <hr>
  
  <p>If You want to copy files inside one heap folder:</p>
  
  <pre><code>$ find FastQC/ -type f -name "*.fastq.gz" -print0 | xargs -0 -I {} cp -pv {} FastQC_heap/
  `FastQC/T9/Infected/Rep1/test11.fastq.gz' -&gt; `FastQC_heap/test11.fastq.gz'
  `FastQC/T9/Infected/Rep1/test1.fastq.gz' -&gt; `FastQC_heap/test1.fastq.gz'
  `FastQC/T9/Infected/Rep2/test2.fastq.gz' -&gt; `FastQC_heap/test2.fastq.gz'
  `FastQC/T9/Infected/Rep3/test3.fastq.gz' -&gt; `FastQC_heap/test3.fastq.gz'
  </code></pre>
   292: <p>This is the typical kind of job for <a href="https://snakemake.readthedocs.io/en/stable/" rel="nofollow noreferrer">snakemake</a>.</p>
  
  <p>Assuming your have one file per replicate named for instance <code>T9/Infected/Rep1/Rep1.fastq.gz</code>, you can prepare a file that you call <code>Snakefile</code> with the following content:</p>
  
  <pre class="lang-python prettyprint-override"><code>timepoints = list(range(10))
  conditions = ["control", "infected"]
  replicates = [1, 2, 3]
  
  rule all:
      input:
          expand(
              "T{time}/{cond}/Rep{rep}/Rep{rep}_fastqc.html",
              time=timepoints,
              cond=conditions,
              rep=replicates)
  
  rule do_fastqc:
      input:
          fastq = "T{time}/{cond}/Rep{rep}/Rep{rep}.fastq.gz"
      output:
          html = "T{time}/{cond}/Rep{rep}/Rep{rep}_fastqc.html"
      shell:
          """
          fastqc {input.fastq}
          """
  </code></pre>
  
  <p>Put this file in the directory that contains the <code>T*</code> directories and run <code>snakemake</code> from there.</p>
  
  <p>The top <code>all</code> rule explains which files you want. The <code>do_fastqc</code> rule explains how to make one fastqc report from one fastq.gz file.</p>
  
  <p>With a bit more work, this can be used to submit jobs to a computing cluster. Snakemake has <a href="https://snakemake.readthedocs.io/en/stable/executable.html#cluster-execution" rel="nofollow noreferrer">some tools for this</a>.</p>
  
  <p>If you don't know the exact names of the fastq files but they all follow the same pattern, you will need to use the <code>glob</code> python module and do a little bit of programming to determine the possible values for <code>rep</code>, <code>cond</code> and <code>time</code>. The "snakefile" can contain any python code you want.</p>
  
  <p>If there are no regular pattern in the file names, fix this issue first ;)</p>
   2085: <p><code>multiqc</code> kind of glazes over some important information, like the exact adapters and duplicated sequences in a library. If you plan to spend big $$ for sequencing a library it is better to look at both the <code>multiqc</code> report and the actual fastqc <code>html</code> report to get a better idea of any error modes. </p>
  
  <p>Going off of @Kubator's answer, I noticed that there was no command to run fastqc.</p>
  
  <p>Here's a simple one-liner to run fastqc in parallel on all of your fastq files. The <code>-j 25</code> uses 25 threads. Change <code>25</code> to however many threads you want/have for max speed.</p>
  
  <pre><code>#Run fastqc on everything in parallel.
  &gt; find ../reads/ -name '*.fastq.gz' | awk '{printf("fastqc \"%s\"\n", $0)}' | parallel -j 25 --verbose
  # copies all the fastqc files to directory ./    
  &gt; find ../reads/ -name '*fastqc.*' | xargs -I '{}' mv '{}' ./
  </code></pre>
  
  <p>These files might be output by <code>multiqc</code>, anyway!</p>
  
  <p>edit - now the command is safe for whitespace in file names. Please, no newlines in filenames though!</p>
  