Skip to content

file.getName() doesn't strip the parent directory as described in the documentation. #5718

@mahesh-panchal

Description

@mahesh-panchal

Bug report

Expected behavior and actual behavior

When using the getName() method on TaskPath objects, it should just output the filename and not the parent directory if the file gets staged in a subdirectory of a process. The actual behaviour is that getName provides the full staged path, unlike getBaseName which does strip the parent directory.

Steps to reproduce the problem

workflow {
    TASK( Channel.fromPath(['data/sampleA.ext.gz','data/sampleB.ext.gz','data/sampleC.ext.gz']).collect() )
        .view()
}

process TASK {
    input:
    path files_in, stageAs: 'zipped/*'

    script:
    """
    echo "${files_in*.name}"
    echo "${files_in*.baseName}"
    """

    output:
    stdout
}

Program output

$ nextflow run main.nf

 N E X T F L O W   ~  version 24.10.4

Launching `main.nf` [big_davinci] DSL2 - revision: b223d1ff7a

executor >  local (1)
[c0/b424af] process > TASK [100%] 1 of 1 ✔
[zipped/sampleA.ext.gz, zipped/sampleB.ext.gz, zipped/sampleC.ext.gz]
[sampleA.ext, sampleB.ext, sampleC.ext]

Environment

  • Nextflow version: 24.10.4
  • Java version: openjdk 17.0.14-internal 2025-01-21
  • Operating system: Linux
  • Bash version: GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions