DATASETS1 = ["1", "2", "3"] DATASETS2 = ["1", "2", "3"] rule all: input: expand("OUT2/{d1}_{d2}.sorted.txt", d1=DATASETS1, d2=DATASETS2) rule sort: input: a="IN3/{dataset1}.txt", b="IN4/{dataset2}.txt", output: "OUT2/{dataset1}_{dataset2}.sorted.txt" shell: "cat {input.a} {input.b} > {output}" rule create3: input : output : "IN3/{dataset}.txt" shell : "echo {output} > {output}" rule create4: input : output : "IN4/{dataset}.txt" shell : "echo 1 > {output}"