File Mover Blog

  • 26 May

    Move 1 file to 1 location and another file to a different location

    Q: Is it possible to move 1 file to 1 location and another file to a different location but only when a file with a specific extension is present? I’m processing a job where I create a data file with print information and a PDFfile,  in the Main location there will be .csv file

    Main Location

    .csv

    At some point a pdf file will appear in the main location i.e.

    .csv

    .pdf

    Can I create a rule where

    1. It only starts when a .pdf is present
    2. Moves the .pdf file to 1 location and the .csv file to a different location?

    A: Yes this is possible using a bit of Pascal Script. We added some screenshots from an example to get you started.

    • We added a local Windows folder as Source:

    Limagito File Mover Source Setup

    • Important is to add the following FileName Include Filters. We’ll scan for ‘*.csv’ and ‘*.pdf’ files.

    Limagito File Mover Filename Include Filter

    • Open the Pascal Script option:

    Limagito File Mover Pascal Script option

    • Enable and Add the following ‘On Rule Begin’ Pascal Script:
    Begin
      psExitCode:= 1;
      // ... add your code here
      psVSA := '';
    End.
    

    Limagito File Mover Pascal Script

    • Enable and Add the following ‘On Destination’ Pascal Script:
    Var
      tmpExt: String;
      tmpFile: String;
    Begin
      psExitCode := 0;
      // ... add your code here
      tmpExt := ExtractFileExt(psFileName);
      // Check for pdf if csv exists
      If tmpExt = '.csv' Then
      Begin
        tmpFile := psStringReplace(psFileName, tmpExt, '.pdf');
        If FileExists(psFilePath + tmpFile) or (Pos(psFilePath + tmpFile, psVSA) <> 0) Then
        Begin
          psLogWrite(1, '', 'File ' + tmpFile + ' Exists');
          psVSA := psVSA + ';' + psFilePath + psFileName;
          psExitCode := 1;
        End;
      End;
      // Check for csv if pdf exists
      If tmpExt = '.pdf' Then
      Begin
        tmpFile := psStringReplace(psFileName, tmpExt, '.csv');
        If FileExists(psFilePath + tmpFile) or (Pos(psFilePath + tmpFile, psVSA) <> 0)  Then
        Begin
          psLogWrite(1, '', 'File ' + tmpFile + ' Exists');
          psVSA := psVSA + ';' + psFilePath + psFileName;
          psExitCode := 1;
        End;
      End;
    End.
    

    Limagito File Mover Pascal Script

    • Enable and Add the following ‘On Destinations‘ Pascal Script:
    Begin
      psExitCode := -1;
      // .csv files to Destination ID1
      If (psDestinationID = 'ID1') And (ExtractFileExt(psFileName) = '.csv') Then
        psExitCode := 1;
      // .pdf files to Destination ID2    
      If (psDestinationID = 'ID2') And (ExtractFileExt(psFileName) = '.pdf') Then
        psExitCode := 1;
    End.
    

    Limagito File Mover another file to a different location

    • Add two Destinations. Important, the first Destination (ID1) should receive hte csv files and the second Destination (ID2) should receive the pdf files.

    Limagito File Mover Destination Setup

    • RunTime Log Result. The Csv file goes to the first Destination and only when a pdf file with the same name exists. The pdf file itself goes to the second Destination.

    Limagito File Mover RunTime Log

    #Filetransfer #Filemanagement

    If you need any info about this request, please let us know.

    Best regards,

    Limagito Team

    By Limagito-Team Pascal Script WIN
  • 25 May

    Treatment Error in PGP Decryption

    Q: Treatment Error in PGP Decryption. I am writing a rule to decipher pgp files. Sometimes, I may have some error (ie. bad pgp key). In this case, I have the following error:

    Limagito File Mover Treatment Error

    I would like in this case to move the file in an other directory (ie. FILE IN ERROR). Is it possible ?

    A: Yes this is possible. We’ll use our Rule Events ‘On Error’ option. This event is triggered when an error occurs, in this case with the decryption in the Destination. We added some screenshots to get you started.

    • Please open the ‘Rule Events’ setup:

    Limagito File Mover Rule Events

    • Enable ‘On Error’ and add and enable the following ‘Pascal Script’ (be sure ‘On Error’ is selected). Don’t forget to adjust the ctErrorPath const.
    Const
      ctErrorPath = 'C:\Temp\'; // path must end with /
    Begin
      psExitCode:= 1;
      // ... add your code here
      psMoveFile(psFilePath + psFileName, ctErrorPath + psFileName);
    End.
    

    Limagito File Mover Rule Events Pascal Script

    Feedback customer:

    In the meanwhile, I had found another solution using command on the event After Move Error. But I switched back to your solution.

     

    #Filetransfer #Filemanagement

    If you need any info about this ‘Treatment Error in PGP Decryption’ question, please let us know.

    Best regards,

    Limagito Team

1 40 41 42 43 44 45 46 135
SEARCH