Your suggestion works really nice, thank you! Still there is something like a bug or not sure how to describe it. Right now the script above deletes the files, no matter if the download was successful or if you refresh (using the f5) or log off your account, via the web browser (for example logging into the sftp by using browser). Any idea what could cause that, since only the "download file" event is checked?