WinAutomation - windows automation software with macro recorder
About Softomotive

      Delete Files in FTP older than 2 Weeks

      Ever wanted to get rid of files that you have not accessed in your server after backing it up? Storing a great deal of data in a machine and making backups of the same information again and again is not so useful, since some files are not meant to be modified after being sent on the server and are not used by anyone (so no one will miss them if they cannot access them directly), and they can always be found in a backup.

      Using WinAutomation, you can create a job that will do this for you, without you having to go through each files properties again and again and check which files have been modified since your last backup.

      To start with, we make sure we get the current date.

      We open the FTP Connection and we can either type the information of the ftp connection so that no user intervention is needed, or if we will be using the same job for more than one connections we can set up input dialogs to specify our options every time.

       

      We should then get the list of the FTP Directory of our FTP Connection and we tell it to check the last modified properties of each file and compare it to the current date, so that we know whether it has been modified within the last 14 days.

          

      If the file has not been modified within the last 14 days, it has been told through the if condition that it should delete it.


      This can also work for local machines and folders, there’s an example in WinAutomation, within the Intermediate section of the preset Examples that allows the user to find the files that have been modified since Yesterday. Using the same philosophy, we can customize this job to get an equivalent “delete files” of a folder that runs on our computer.

      AttachmentSize
      003_Delete Files in FTP older than 2 Weeks.waj17 KB
      No votes yet

      Comments:
      #1 by Samantha - Fri, 05/14/2010 - 12:19

      Very well spotted Erica, thanks for paying attention. You are right, the date subtraction should not be included in the if condition. The blog has been updated :)


      #2 by Erica (not verified) - Thu, 05/13/2010 - 23:35

      I am wondering about this code, because you evaluate %DaysOld% prior to setting it's value! Step 9 should be ahead of step 8. You may get lucky and have things work anyway but it isn't guaranteed.



      #3 by Samantha - Sat, 05/01/2010 - 11:43

      Cheers! It'll show now! ;)



      #4 by Will (not verified) - Sat, 05/01/2010 - 01:54

      First image in the series doesn't display. Link seems to be broken. ;)



      Post new comment

      The content of this field is kept private and will not be shown publicly.
      • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <p>
      • Lines and paragraphs break automatically.
      • Web page addresses and e-mail addresses turn into links automatically.
      • You may quote other posts using [quote] tags.

      CAPTCHA
      This question is for testing whether you are a human visitor and to prevent automated spam submissions.

      Featured Clients




      Monthly Blog Archive