rule clean_files: input: "{sample}/profiles/{database}/{tool}.profile.out" output: touch("{sample}/profiles/{database}/{tool}_clean_files.done") log: "{sample}/log/{database}/{tool}_clean_files.log" benchmark: "{sample}/log/{database}/{tool}_clean_files.time" run: if not config["keepfiles"]: # Remove individual folder (sample/tool/database) shell("rm -rfv {wildcards.sample}/{wildcards.tool}/{wildcards.database}/ > {log} 2>&1") # Remove tool folder if it existst and there's no more data (sample/tool) shell('if [ -d "{wildcards.sample}/{wildcards.tool}/" ]; then if [ ! "$(ls -A {wildcards.sample}/{wildcards.tool}/)" ]; then rm -rfv {wildcards.sample}/{wildcards.tool}/ >> {log} 2>&1; fi; fi')