Niklas Schandry
06/30/2026, 8:54 AMfile.name and file.baseName :
I am trying to do something very simple: if a file is zipped (bz2, xz, gz) I want to remove the extension, if it is not, then keep it.
outname = ["xz", "bz2", "gz"].contains("${infile.extension}") ? "${infile.baseName}" : "${infile.name}"
outfile = task.ext.prefix ? "${task.ext.prefix}.gz" : "${outname}.gz"
This works ok for unzipped files, they receive .gz in addition to their original extension, but something that is vcf.gz becomes vcf.gz.gz . It seems like baseName does not remove the extension, but why?Nicolas Vannieuwkerke
06/30/2026, 9:16 AMtask.ext.prefix set as?Niklas Schandry
06/30/2026, 9:20 AMNiklas Schandry
06/30/2026, 9:26 AMbaseName , but to this: ["xz", "bz2", "gz"].contains("${infile.extension}")Niklas Schandry
06/30/2026, 9:39 AMdef prefix = task.ext.prefix ?: (in_ext == "xz" || in_ext == "bz2" || in_ext == "gz") ? "${infile.baseName}" : "${infile.name}"Niklas Schandry
06/30/2026, 9:44 AMfile.extension.toString() fixes this, but I do not understand why the extension is not a string to being with?mashehu
06/30/2026, 9:54 AMNiklas Schandry
06/30/2026, 9:55 AM