File Mover Blog

  • 18 Jul

    LimagitoX Pascal Script Example

    We get a lot of custom requests. We can’t add them all to LimagitoX File Mover so that is why the Pascal Script option was added.  To understand the possibilities of Pascal Script we will add some cases to our blog. Please feel free to ask us about the Pascal Script possibilities.

    Customer Request:

    Secondly, the destination for the moving rule is in two seperate locations. Essentially, files from 1-5000 need to go to one location and files over 5001 need to go to another. Is this a job for pascal script? If so do you know of any good tutorials on how to write it? The files are named 1Filename, 2Filename … all the way to 5000Filename

    Our solution was the following:

    Add two destinations:
    – files from 1-5000 need to go to one location => FIRST DESTINATION
    – and files over 5001 need to go to another. => SECOND DESTINATION
    Add the following ‘On Destinations’ Pascal Script:
    var
      i: integer;
      tmpInt: Integer;
      tmpStr: String;
    Begin
      psExitCode:= 0;
      // … add your code here
      tmpInt := -1;
      // Get Number Prefix
      for i := 4 downto 1 do
      begin
        tmpStr := LeftStr(psFilename, i);
        try
          tmpInt := StrToInt(tmpStr);
        Except
          //
        End;
        If tmpInt <> -1 Then
          Break;
      end;
      // Check Number Prefix
      If tmpInt <> -1 Then
      Begin
        If (tmpInt <= 5000) And (psDestinationID = ‘ID1’) Then
          psExitCode := 1;
        If (tmpInt > 5000) And (psDestinationID = ‘ID2’) Then
          psExitCode := 1;
      End
      Else
        psLogWrite(2, ‘[Prefix Number Check]’, ‘Not a valid prefix, ‘ + psFilename);
    End.

     

    By Limagito-Team Pascal Script
SEARCH