Pascal Script

  • 20 Jul

    How to halt moving too many files and send an alert

    How to halt moving too many files and send an alert

    Q: I have a job that moves files from an external S3 bucket into our local storage. The other day a vendor hiccupped and sent 8000 files. Limagito did it’s job and moved them over, which ended up gumming up our systems. Is there any way to limit transfers? I’ve been looking through Help and haven’t seen anything yet.

    For instance…I know this vendor normally sends around 10 a month. Anything over 50 would obviously be abnormal and It would be great to throttle them, even better to send an alert and let us know, so we can correct the issue.

    Any help would be greatly appreciated.

    A: Please have a look at the following setup. So we’ll allow only a maximum of files per month.

    • We used a Windows folder as Source:

    halt moving too many files

    – Function Setup > set Destination Options to ‘Destination Memory & Exit Cyclus on Error’

    limagito file mover function setup

     – Destination Setup:
    • First Destination: Pascal Script
      • This script will check the month and the amount of files it successfully moved
      • You can adjust the “ctMaxFilesAllowed” Const value to allow more or less files per month
    • Second Destination: your output, can be any Destination type.
    • Third Destination: Pascal Script
      • Will increase the internal counter (VIA) if a file is successfully moved
    Link to both scripts, for the first and third Destination.
    limagito file mover Destination setup
    First Destination (Pascal Script):
    limagito file mover halt moving too many files
    Third Destination (Pascal Script):
    limagito file mover halt moving too many files
    – Open Our Rule Events option:
    limagito filemover rule events option
    – Select and enable ‘On Pascal Script Error’ event. Enable ‘Enable Mail’ and adjust the mail setup. There is a test button available.
    limagito file mover rule events setup
    Enable the ‘Error event memory’ because otherwise you’ll get too many emails in case the maximum of files is reached.
    limagito file mover rule events setup
    FYI: When you would test this setup and max files are reached we added a way to reset the internal counter (max files allowed per month).
    Right click on the Counter value below and select ‘Reset Counter’.
    limagito file mover reset counter

    This is is just an example of what is possible. If you need any help with this ‘halt moving too many files’ setup, please let us know.

    Best Regards,

    Limagito Team

    #managedfiletransfer #filetransfer #filemanagement

  • 30 Jun

    How to move files to different destinations based on the file extension

    How to move files to different destinations based on the file extension

    Q: Since we are dealing with Pharma equipment where we are pulling data off. We would like to be able to split the data into ‘readable’ (ie Txt, excel) and permanent (ie PDF, Image) and place the file types in different subdirectories on the target. At this time, my only solution would be to create two separate rules to accomplish this. Given that there are so many features hidden in your tool that I keep learning about, I was wondering if that was a feature that is in the Mover that I have not found.

    A: Yes this is possible using our Script option.

    • We used a Windows Folder as Source:

    limagito file mover windows folder as source

    • We added the following Filename Include Filters. These are the file extensions we want to split to different destinations.

    limagito file mover filename filter

    • In this example we added 4 destinations. Each Destination has a unique ID:
      • ID1
      • ID2
      • ID3
      • ID4

    We’ll use this Destination ID in our script.

    limagito file mover destination setup

    • Next, please open our Pascal Script option:

    limagito file mover pascal script option

    • Enable and add the following ‘On Destinations’ Pascal Script:
    Var
      tmpFileExt: String;
    Begin
      psExitCode:= -1;
      // ... add your code here
      tmpFileExt := ExtractFileExt(psFilename);
      // psLogWrite(1, '', 'Check File Extension ' + tmpFileExt + ' from ' + psFilename);
      // Check If Destination ID is ID1 AND do we have a .txt file?
      If (psDestinationID = 'ID1') Then 
        If SameText(tmpFileExt, '.txt') Then
          psExitCode := 1; 
      // Check If Destination ID is ID2 AND do we have .xls/.xlsx files?
      If (psDestinationID = 'ID2') Then
        If SameText(tmpFileExt, '.xls') OR SameText(tmpFileExt, '.xlsx') Then
          psExitCode := 1; 
      // Check If Destination ID is ID3 AND do we have a .pdf file?
      If (psDestinationID = 'ID3') Then 
        If SameText(tmpFileExt, '.pdf') Then
          psExitCode := 1;  
      // Check If Destination ID is ID4 AND do we have .png/.jpg/.bmp files?
      If (psDestinationID = 'ID4') Then
        If SameText(tmpFileExt, '.png') OR SameText(tmpFileExt, '.jpg') OR SameText(tmpFileExt, '.bmp') Then
          psExitCode := 1;       
    End.

    limagito file mover different destinations based on the file extension

    • RunTime Log Result:

    limagito file mover runtime log

    This is is just an example of what is possible. If you need any help with this ‘different destinations based on the file extension’, please let us know.

    Best Regards,

    Limagito Team

    #managedfiletransfer #filetransfer #filemanagement

  • 20 Apr

    How to export all rules to CSV with column name, source and destination

    Is there a way to export all Limagito rules to CSV or Excel with the column of name, source and destination?

    In a recent version of Limagito File Mover we added the following Pascal Script function to achieve this:

    Function psExportRuleDataAsCSV(Const aFile, aData, aDelimiter: String): String;

    aFile = Output Csv file, e.g. ‘C:\Temp\RuleList.csv’
    aData = a ; seperated list of items you want to add ( When empty string we’ll use ‘1;2;3;4’ )
    1 = RuleID
    2 = DisplayName
    3 = Source
    4 = Destination
    7 = Information
    aDelimiter = csv delimiter used in the csv outputfile

     

    • Setup is easy, you’ll only need to add our ‘Pascal Script’ option as Source

    limagito file mover pascal script as source

    • Do not forget to adjust the ‘ctOutputCsv’ const:
      • Please add the following script: link

    limagito file mover export all rules to CSV

    • This is all you need to do, just enable and trigger the Rule now
    • Output Csv file content:

    RuleID,DisplayName,Source,Destination
    1,UNZIP Files Mike,[WIN]C:\Test\Out_Zip\,ID1[ZIP]C:\Test\Out_Zip\Out\
    2,WIN > Google Cloud Storage,[WIN]C:\Test\In\,ID2[GCLOUD]storage.googleapis.com/limagito/test
    3,GCloud > WIN,[GCLOUD]storage.googleapis.com/limagito/Test,ID1[WIN]C:\Test\Out\GCloud\

    If you need any help with our new ‘export all rules to CSV’ feature, please let us know. If you need more fields, please let us know.

    Best Regards,

    Limagito Team

    #managedfiletransfer #FileManagement #filetransfer

1 2 3 4 27
SEARCH