diff --git a/fastqc.wdl b/fastqc.wdl
index b361f10d59c0731d195254f7f281580d1d15c8de..f0fd2fec0371432f054aecd9624dc9bda628f292 100644
--- a/fastqc.wdl
+++ b/fastqc.wdl
@@ -15,7 +15,11 @@ task fastqc {
     File? limits
     Int? kmers
     String? dir
-
+    # Chops of the .gz extension if present.
+    String name = sub(seqFile, "\\.gz$","")
+    # This regex chops of the extension and replaces it with _fastqc for the reportdir.
+    # Just as fastqc does it.
+    String reportDir = outdirPath + "/" + sub(basename(name), "\\.[^\\.]*$", "_fastqc")
     command {
     set -e -o pipefail
     ${preCommand}
@@ -40,11 +44,6 @@ task fastqc {
     }
 
     output {
-        # Chops of the .gz extension if present.
-        String name = sub(seqFile, "\\.gz$","")
-        # This regex chops of the extension and replaces it with _fastqc for the reportdir.
-        # Just as fastqc does it.
-        String reportDir = outdirPath + "/" + sub(basename(name), "\\.[^\\.]*$", "_fastqc")
         File rawReport = reportDir + "/fastqc_data.txt"
         File htmlReport = reportDir + "/fastqc_report.html"
         File summary = reportDir + "/summary.txt"