Submit a ticketCall us

WebinarUpcoming Webinar: Know What’s Changed – with NEW Server Configuration Monitor

Change management in IT is critical. But, even with a good change management process, changes are too often not correctly tracked, if at all. The configuration of your servers and applications is a key factor in their performance, availability, and security. Many incidents can be tracked back to an authorized (and sometimes unauthorized) configuration change, whether to a system file, configuration file, or Windows® Registry entry. Join SolarWinds VP of product management Brandon Shopp to discover how the new SolarWinds® Server Configuration Monitor is designed to help you.

Register now.

Home > Success Center > Serv-U Managed File Transfer & Serv-U FTP Server > Serv-U - Knowledgebase Articles > Automatically delete files after downloading in Serv-U

Automatically delete files after downloading in Serv-U

Table of contents

Updated July 25, 2018

Overview

You can use the "file download" event in Serv-U to run a batch file that automatically deletes files from certain folders after they are downloaded.

Environment

All Serv-U versions

Steps

  1. If you do not already have them, create a local folder for Serv-U batch files and a local folder for Serv-U logs.
  2. Create a batch file named deletefileafterdownload.bat in your Serv-U batch file folder. Copy/paste this text in:
    time /t >> D:\local\ServU_One\Log\DeleteFileAfterDownload.log
    echo Deleted %1 >> D:\local\ServU_One\Log\DeleteFileAfterDownload.log
    del %1 >> D:\local\ServU_One\Log\DeleteFileAfterDownload.log
    
  3. Before you save the batch file, change the log path ("D:\local\ServU_One\Log") to your Serv-U log path.

    Do not worry about creating the "DeleteFileAfterDownload.log" file. When Serv-U runs this batch file, it will be done automatically.

  4. Create a new domain-level event called "Delete File After Download".

    Event type File Download
    Event Name Delete File After Download
    Enable Event Checked
    Description (write which folders this applies to)
    Action Execute Command
    Executable Path (full path of deletefileafterdownload.bat)
    Command Line Parameters $LocalPathName
    Completion Wait Time 0
  5. Flip to the "Event Filters" tab on your new event and add an Event Filter:

    event_filter.jpg

    Name Just Folders Named (whatever your folder criteria are)
    Logic (doesn't matter if you only have one filter rule)
    Filter Enabled Checked
    Description (optional)

    Rule:

     

    Variable $PathName
    Comparison = (is equal to)
    Constant *dad* (change as necessary; just "*" will match all)
    Data Type (abcd) string
  6. Test the process:
    1. Sign on as an end user.
    2. Download a file from a folder that should trigger the event.
    3. Check that the event firing was noted in the Serv-U domain log, and also check that a new "Deleted (filename)" entry appeared in the DeleteFileAfterDownload.log file. Also, refresh your directory listing in the client you used to perform the download to verify that the file is gone.
    4. Now download a file from a folder that should NOT trigger the event and check that the event did not fire.
  7. Optimize.

    • You may want to remove the statements that log to a separate file after you are sure the process works. In that case, the batch file will function with just a single command on a single line: "del %1".

    • Experiment with different event filters to get the delete event to trigger on different combinations of file names and folder names.

 

 

Last modified

Tags

Classifications

Public