<p>I think you'll need to convert your <code>Array[File?]+</code> to a <code>Array[File]</code> before you can use <code>~{sep=&quot; &quot; files}</code> in the command section.</p>
<p>You can use the <code>select_all</code> function for that, which will only keep valid files.</p>
<p><a href="https://github.com/openwdl/wdl/blob/main/versions/development/SPEC.md#arrayx-select_allarrayx" rel="nofollow noreferrer">https://github.com/openwdl/wdl/blob/main/versions/development/SPEC.md#arrayx-select_allarrayx</a></p>

CC BY-SA 4.0
2021-07-19T20:17:39.510Z
2021-07-19T20:17:39.510Z
Lucas van Dijk
<p>I tried to add a &quot;gather_results&quot; task to a workflow that takes in an array of Files and moves output files to a new folder of a specified name.</p>
<p><code>Cannot interpolate Array[File?]+ into a command string with attribute set wdl PlaceholderAttributeSet(None,None,None,Some( ))]</code></p>
<p>The wdl file passes womtools and I have no idea what a PlaceholderAttributeSet is, which makes debugging quite difficult.</p>
<p>--</p>
<p><strong>gather files task</strong></p>
<pre><code>task gather_result{
  input{
    String dir
    String? subDir
    Array[File?]+ files
  }

  command
  {
    mkdir --parents <span class="math-container">${dir}/$</span>{default=&quot;&quot; subDir}; /bin/mv -t <span class="math-container">${dir}/$</span>{default=&quot;&quot; subDir} ${sep=&quot; &quot; files}
  }
  runtime
  {
    docker_image: &quot;pipeline&quot;
    memory: &quot;2 GB&quot;
  }
  output
  {
    String out = stdout()
  }
}

</code></pre>
<p>How it's called:</p>
<pre><code>  call gather_result as gather_files {
      input: files=[create_hic.output_hic[1],
                    dedup.deduped_bam,
                    calculate_stats.stats[0],
                    calculate_stats.stats_hists[0],
                    calculate_stats.stats_json[0]],
            dir=OutputDir
    }

</code></pre>

CC BY-SA 4.0
2021-07-17T21:13:53.867Z
WDL can be a pain. Try and simplify it (reduce input complexity by adding one piece of files at a time). Wil need trial and error. Drop the ? if U can. Check all input types. One might need a flatten.
Liam McIntyre
CC BY-SA 4.0
2021-07-19T03:26:05.793Z
If I drop the ? I get a womtools error saying wld can't interpolate Array[File]+ to Array[File?]+
Henry C Wong
<wdl>
Error when trying to move multiple file types in wdl
# Error when trying to move multiple file types in wdl

(Asked by: username_0 on 2021-07-16)

I tried to add a "gather_results" task to a workflow that takes in an array of Files and moves output files to a new folder of a specified name.
Cannot interpolate Array[File?]+ into a command string with attribute set wdl PlaceholderAttributeSet(None,None,None,Some( ))]
The wdl file passes womtools and I have no idea what a PlaceholderAttributeSet is, which makes debugging quite difficult.
--
gather files task
task gather_result{
  input{
    String dir
    String? subDir
    Array[File?]+ files
  }

  command
  {
    mkdir --parents ${dir}/${default="" subDir}; /bin/mv -t ${dir}/${default="" subDir} ${sep=" " files}
  }
  runtime
  {
    docker_image: "pipeline"
    memory: "2 GB"
  }
  output
  {
    String out = stdout()
  }
}


How it's called:
  call gather_result as gather_files {
      input: files=[create_hic.output_hic[1],
                    dedup.deduped_bam,
                    calculate_stats.stats[0],
                    calculate_stats.stats_hists[0],
                    calculate_stats.stats_json[0]],
            dir=OutputDir
    }

**Tags:** wdl
> **Comments:**
> **username_1**: WDL can be a pain. Try and simplify it (reduce input complexity by adding one piece of files at a time). Wil need trial and error. Drop the ? if U can. Check all input types. One might need a flatten.  
> **username_0**: If I drop the ? I get a womtools error saying wld can't interpolate Array[File]+ to Array[File?]+  

---

## 1 answers

### Answer by username_2 on 2021-07-19. Score: 1

I think you'll need to convert your `Array[File?]+` to a `Array[File]` before you can use `~{sep=" " files}` in the command section.

You can use the `select_all` function for that, which will only keep valid files.

<https://github.com/openwdl/wdl/blob/main/versions/development/SPEC.md#arrayx-select_allarrayx>


---

