Delete

  • 01 Aug

    How to delete Folders based on the name of the folder

    Q: How to delete Folders based on the name of the folder.

    The schema is:

    username_YYMMDD-HHMMSS

    is it possible to extract the date and use it as condition to check if it is older than x days and than delete the folder and all of its content?

    limagito file mover delete Folders based on the name

    A: Yes, this is possible using some Pascal Script.

    • Source should be a Windows Folder or Share. We used the following folder as Source:

    limagito file mover windows folder as source

    Or test content looks like:

    limagito file mover Delete Folders based on date in Folder Name

    • Pascal Script Setup

    limagito file mover pascal script option

    • Enable ‘On Rule Begin’ Pascal Script option and copy/paste the script from here: link
      • Do not forget the adjust the ctOlderThanDay Const value. We used 500 days.
      • The Date format we used was YYMMDD

    limagito file mover pascal script setup

    • File Filter Setup

    limagito file mover file filter setup

    • Directory Setup

    limagito file mover directory setup

    • The %VSA (= Var String A) is used as directory filter. The previous Pascal Script will add the Subfolders to delete (older than x days) into this var.

    limagito directory setup

    • Function Setup

    limagito file mover function setup

    • RunTime Log Result:

    limagito filemover runtime log result

    • Source Content Result:

    limagito filemover delete Folders based on the name

    If you need any help with this ‘delete Folders based on the name’ request, please let us know.

    Best Regards,

    Limagito Team

    #managedfiletransfer #filetransfer #filemanagement

  • 08 Dec

    How to email a list of deleted files

    How to email a list of deleted files

    Q: I want to email a list of deleted files on a weekly base. Is this possible with Limagito File Mover.

    A: You could use our ‘Logging to File’ option but in this case the customer wanted a custom list file so we used our scripting option.

    • First you’ll need to setup your delete Rule. We used a Windows Folder as Source:

    limagito file mover Windows folder as source

    • Set Function To ‘Delete Files’:

    limagito file mover list of deleted files

    • Open our ‘Rule Events’ option:

    limagito file mover rule events option

    • Enable ‘On Success’ Event and add the following Pascal Scriptt:
      • do not forget to adjust the ctOutputFile Const
        • We used ‘C:\Test\FileToSend.txt’
    Var
      tmpList: TStringList;
    Const
      ctOutputFile = 'C:\Test\FileToSend.txt';
    Begin
      psExitCode:= 1;
      // ... add your code here
      tmpList := TStringList.Create;
      Try
        Try
          If FileExists(ctOutputFile) Then
            tmpList.LoadFromFile(ctOutputFile)
          Else
            tmpList.Add('Files deleted since ' + FormatDateTime('d mmmm yyyy', Now));          
          // Add Info
          tmpList.Add(FormatDateTime('YYYY/MM/DD HH:NN:SS', Now) + ' Deleted File: ' + psFilePath + psFileName);
          // Save
          tmpList.SaveToFile(ctOutputFile)          
        Except
          psLogWrite(1, '', 'Could not adjust file: ' + ctOutputFile); 
        End;
      Finally
        tmpList.Free;
      End;
    End.

    limagito file mover list of deleted files

    • Next add a second Rule which you’ll trigger once a week. Let the second Rule ‘Move’ the create file ‘C:\Test\FileToSend.txt’ (previously defined inthe script of the delete Rule as ctOutputFile) and use SMTP (email) as Destination.
      • We would use our schedule option to move this listing file once a week
        • The example is set to every Monday at 6:00 AM

    limagito file mover schedule option

    If you need any help with this “list of deleted files” question, please let us know.

    Best Regards,

    Limagito Team

    #managedfiletransfer #filetransfer #filemanagement

SEARCH