Pascal Script

  • 24 Mar

    Move txt files if the line count is more than one

    Q: I am looking to move txt files to a location. If the line count is more than 1 (more than just a header) move to processing.
    A: Yes this is possible using some Pascal Script.

    1. Be sure that you will only handle text files. We’ve added a File Name Include Filter:

    Limagito File Mover Filename Filter

    2.Please open the ‘Pascal Script’ option:

    Limagito File Mover Pascal Script option

    3. Enable and Add the following ‘On Destination’ Pascal Script. You can choose between 0 or -1 as result for psExitCode var. 0 will give an error when such a file is found, -1 will skip such a file.

    Var
      tmpFile: String;
      tmpList: TStringList;
    Begin
      psExitCode:= 1;
      // ... add your code here
      tmpFile := psFilePath + psFileName;
      tmpList := TStringList.Create;
      Try
        Try
          tmpList.LoadFromFile(tmpFile);
          If tmpList.Count < 2 Then
          Begin
            // Invalid count
            psExitcode := -1; // := -1 is Skip File and := 0 is Error on File
            psLogWrite(1, '', 'Invalid recordcount in ' + tmpfile);      
          End;  
        Except
          // Error
          psExitCode := 0;
          psLogWrite(1, '', 'Error loading ' + tmpfile);
        End;
      Finally
        tmpList.Free;
      End;  
    End.

    Limagito File Mover Line Count is more

    4. RunTime Log

    Limagito File Mover RunTime Log

    #Filetransfer

    If you need any info about this ‘line count is more than’ request, please let us know.

    Best regards,

    Limagito Team

    By Limagito-Team Pascal Script
  • 23 Mar

    Keep a number of files in a specific delete Folder I’m watching in

    Q: Is there any option for a delete rule to keep a number of files, e.g. keep the last 10 Files, in the specific delete Folder I’m watching in?

    We’re trying to handle our LOG Folder with Limagito. These LOG Files are not written permanently within a specific timeslot so it would be great to have this Log Rotation Option. Maybe there is a scriptsolution?

    A: Yes this is indeed possible with Pascal Script (we tested this with version v2022.3.18.0).

    1.Function is set to Delete

    2.Source must be a Windows Folder or share

    3. Set ‘Source File Sort Order’ to ‘File last write date ascending (Old to New)

    Limagito Source File Sort Order

    4.Open Pascal Script setup:

    Limagito File Mover Pascal Script option

    5.Enable and add the following ‘On Destination’ Pascal Script (you can adjust the Const values of ctKeepFiles, ctSearchExt and ctSearchSubDirs):

    Var
      tmpCount: Integer;
    Const
      ctKeepFiles = 10;
      ctSearchExt = '*.log';
      ctSearchSubDirs = True; // True or False
    Begin
      // ... add your code here
      tmpCount := psCountFiles(psFilePath, ctSearchExt, ctSearchSubDirs);
      // Check
      If tmpCount > ctKeepFiles Then
      Begin
        psExitCode := 1;
      End
      Else
      Begin
        psLogWrite(1, '', 'Skip Delete, Minimum count reached');
        psExitCode := -2;
      End;
    End.

    Limagito File Mover keep the last 10 Files

    You’ll find ‘Skip Delete’ in the RunTime Log when the minimum amout of log files needed is reached. Further deletes will be skipped.

    Limagito File Mover RunTime log

    #Filetransfer

    If you need any info about this ‘keep a number of files’ request, please let us know.

    Best regards,

    Limagito Team

    By Limagito-Team Pascal Script ,
  • 20 Mar

    Q&A 48: Get an actual Rule Report for all Rules we currently have

    Q: I have been asked the second time now if it is possible that I got out an actual Rule Report for all Rules we currently have in Limagito. It`s just all the reporting and documentation obligations our company has to follow. Of course it would be possible to print that on a per Rule-Basis. It would be great if there is an option to generate all Rule-Reports for all Rules at once
    A: Yes this is possible using some Pascal Script. We added some screenshots to get you started.

    1. Add the following Pascal Script as Source (do not forget to adjust the ctDestPath). Our Report output path will be C:\Test\Reports\.

    Var
      tmpInfo: String;
    Const
      ctDestPath = 'C:\Test\Reports\';
    Begin
      psExitCode:= 1;
      // ... add your code here
      tmpInfo := psSaveRuleReportsAsHTML(ctDestPath);
      psLogWrite(1, '', tmpInfo);
    End.

    Limagito File Mover Pascal Script as Source

    2. In this example we disabled the scan timers because we will trigger the rule manually:

    Limagito File Mover Schedule Setup

    3. No Destinations are needed:

    Limagito File Mover Destination Setup

    4. We enabled the Rule and clicked the trigger button (small green arrow on he right of the enable/status button):

    Limagito File Mover trigger rule

    5. Result in the output folder, all the rule reports are saved as html:

    Limagito File Mover Rule Report for all Rules

    #Filetransfer

    If you need any info about this ‘Rule Report for all Rules’ option, please let us know.

    Best regards,

    Limagito Team

1 14 15 16 17 18 19 20 29
SEARCH