Pascal Script

  • 10 Feb

    Send different on success or failure notifications based on file type

    Q: Is it possible in the same moving rule to have it send different on success or failure notifications based on file type. For example I only want it to send a notification if it is a pdf file extension. Other files in the job would still copy but only notify on the pdfs. I am working on a group wide project and it would help out a lot. The PDF file extension was just an example and would be other file formats.

    A: We added a new option ‘Use Pascal Script as event Precondition’ in Version v2022.2.9.0

    – Open Rule Events Setup

    Limagito File Mover Pascal Script Setup

    – Select the Event you want to setup (in our example this is the ‘On Success’ event) > Options Tab > Enable ‘Use Pascal Script as event Precondition’

    Limagito File Mover Pascal Script Use Pascal Script As Precondition

    – Switch to ‘Pascal Script’ Tab and Enable Pascal Script.
    – Add the following script to include only .pdf files for the ‘On Success’ event. This is just a simple example but can be extended to meet all your needs.

    Begin
      // ... add your code here
      If SameText(ExtractFileExt(psFileName), '.pdf') Then
        psExitCode := 1
      Else
        psExitCode := 0;
    End.

    Limagito File Mover Rule Events Pascal Script

    #Filetransfer

    If you need any info about this ‘notifications based on file type’ option, please let us know.

    Best regards,

    Limagito Team

  • 06 Feb

    Maximum number of files in Destination folder

    Q: Maximum number of files in Destination folder. I have a short question. Very nice if You have an answer 🙂

    One Source Windows folder: “IN”.
    One Destination Windows folder: “OUT”
    The number of files in the folder “OUT” should never exceed 3 files.

    (The files will be processed and deleted from the “OUT” folder by other software. When the number of remaining files is 0, 1 or 2, Limagito should send one more file).

    Is there an solution/function for this in Limagito File Mover?

    A: Yes this is possible using a small Pascal Script.

    This script will only work with WIN as Destination. Enable and add ‘On Rule Begin’ Pascal Script. Don’t forget to adjust the ‘ctFilter, ctOutputPath and ctSubDirs’ Const.

    Limagito File Mover Pascal Script option

    Var
      tmpCount: Integer;
    Const
      ctFilter = '*.pdf';
      ctOutputPath = 'C:\Test\Out\Sub1\';
      ctSubDirs = True; // True or False
    Begin
      psExitCode := 1;
      // ... add your code here
      tmpCount := psCountFiles(ctOutputPath, ctFilter, ctSubDirs);
      // Check
      If tmpCount >= 3 Then
      Begin
        psExitCode := 0;
        psLogWrite(1, '', 'QTY Files >= 3 (Count: ' + IntToStr(tmpCount) + ')');
      End;  
    End.

    Limagito File Mover Maximum Files in Destination

    Feedback customer:

    Fantastic! I´ve did some simple tests and it seems to work exactly as we wanted.

    #Filetransfer

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

    Best regards,

    Limagito Team

    By Limagito-Team Pascal Script WIN , ,
  • 14 Nov

    I want to be able to Find in File text content. Is this possible ?

    Q: I want to be able to Find in File text content. Is this possible? For example, if the file contain a string in the file content, than do an operation. Is it possible in Limagito or we can only do something with the file name?

    In attachment, you will find folders and files example.

    –          If we find the string ST^832^ then we need to move the file in the folder « Price »

    –          If we find the string ST^810^ then we need to move the file in the folder « Invoice »

    So, the process should do this :

    –          Move the files !EDIFile.Exaple1 and !EDIFile.Example2 in folder « Price »

    –          Move the file ASSET.Example in folder « Invoice »

    A: Yes this is possible using a custom script which we create for you. I’ve added some screenshots to help you.

    • Source is a Windows folder:

    Limagito File Mover Windows Folder as Source

    • Open ‘Pascal Script’ Setup:

    Limagito File Mover Pascal Script option

    • Enable and add the following ‘On Destination’ Pascal Script:
    Var
      tmpFile: String;
      tmpList: TStringList;
    Const
      ctInvoiceSearch = 'ST^810^';
      ctPriceSearch = 'ST^832^';
      ctInvoiceSubDir = 'Invoice';
      ctPriceSubDir = 'Price';
    Begin
      psVSA := '';
      psExitCode:= 0;
      // ... add your code here
      tmpFile := psFilePath + psFileName;
      tmpList := TStringList.Create;
      Try
        Try
          tmpList.LoadFromFile(tmpFile);
          // Check Invoice
          If pos(ctInvoiceSearch, tmpList.Text) <> 0 Then
          Begin
            psVSA := ctInvoiceSubDir;
            psExitCode := 1;
            psLogWrite(1, '', 'Destination SubDir: ' + ctInvoiceSubDir + ' for ' +tmpFile);
          End;
          // Check Price
          If pos(ctPriceSearch, tmpList.Text) <> 0 Then
          Begin
            psVSA := ctPriceSubDir;
            psExitCode := 1;
            psLogWrite(1, '', 'Destination SubDir: ' + ctPriceSubDir + ' for ' + tmpFile);
          End;
          // Nothing was Found
          If psVSA = '' Then
          Begin
            psLogWrite(1, '', 'Destination SubDir Unknown for ' + tmpFile);
          End;
        Except
          psLogWrite(1, '', 'Error loading ' + tmpFile);
        End;
      Finally
        tmpList.Free;
      End;
    End.

    Limagito File Mover On Destination Pascal Script

    • Set Function to ‘Move Files’:

    Limagito File Mover Function Setup

    • Add ‘WIN’ as Destination

    Limagito File Mover Destination Selection

    • Select your Destination Directory:

    Limagito File Mover WIN as Destination Setup

    • Adjust the default ‘Create Subdir, option’ to:  %VSA\%SFS

    The reason you need to change this is because we’ want to use information from the previous Pascal Script to select the correct Subdirectory. In this example it will be ‘Price’ or ‘Invoice’.

    Limagito File Mover Destination Sub Directory Setup

    • RunTime Log Result:

    Limagito File Mover RunTime Log

    #FileTransfer

    If you need any info about this ‘Find in File text content’ question, please let us know.

    Best regards,

    Limagito Team

    By Limagito-Team Pascal Script WIN , ,
1 13 14 15 16 17 18 19 26
SEARCH