File Mover Blog

  • 21 Jul

    I am looking for a way to incorporate date logic

    Q: I am looking for a way to incorporate date logic within our Limagito installation. I believe the easiest way to do this would be to use a Pascal Script, however I have not been able to find a syntax guide to assist me.

    The date logic would be used in two places in a single rule that is run on a schedule. The first is in the file filter. Rule executes, I need to look for files that meet the pattern: NV_mmddyyyy.pdf where mmddyyyy is the date for the upcoming Friday.

    • If it ran today (July 20, 2022), I would be looking for the filename that matched NV_07222022.pdf

    The second place is in the path to the destination directory. The path looks like: c:\Jobs\mmdd_NV_WK\HotFolders\ where mmdd is the date for the upcoming Friday.

    • If it ran today (July 20, 2022, the path would look like: c:\Jobs\0722_NV_WK\HotFolders\

    Can you help us create a Pascal Script or provide us with a resource that has a syntax guide?

    A: Could you please try the following:

    First enable and add the following ‘On Destination’ Pascal Script

    Limagito File Mover Pascal Script

     
    Var
      tmpDay: TDateTime;
    
    Function GetNextFriday: TDateTime;
    Var
      iDay: Integer;
      tmpDate: TDateTime;
    Begin
      Result := 0;
      tmpDate := Now;
      For iDay := 0 to 6 Do
      begin
        tmpDate := tmpDate + iDay;
        // Check if Friday (= 5)
        If DayOfTheWeek(tmpDate) = 5 Then
        Begin
          Result := tmpDate;
          Break;
        End;
      End;
    End; 
    
    Begin
      psExitCode:= 1;
      // ... add your code here
      tmpDay := GetNextFriday;
      If tmpDay <> 0 Then
      Begin
        psVSA := FormatDateTime('MMDDYYYY', tmpDay);
        psVSB := FormatDateTime('MMDD', tmpDay);
      End
      Else
        psExitCode:= 0;  
    End.
    

    Limagito File Mover Pascal Script

    Next we need to adjust the File Filter Setup. The ‘Include Filename Filter’ will use the %VSA var (%VSA = Var String A) that was set in the previous Pascal Script.

    Limagito File Mover File Filter

    Important, do not forget to enable ‘Allow parameters in File Name filter (File Filter > Advanced Tab)

    Limagito File Mover File Filter

    Next, open Destination Setup and double click on your Destination:

    Limagito File Mover Destinations

    lect File & Directory Tab and adjust ‘Create SubDir, opt.’ to  %VSB_NV_WK\HotFolders\%SFS
    Again we will use a Pascal Script var (%VSB) that was set by the ‘On Destination’ Pascal Script.

    Limagito File Mover Destination Setup

    RunTime Log Result:

    Limagito File Mover RunTime Log

    #Filetransfer #Filemanagement

    If you need any info about this ‘incorporate date logic’ question, please let us know.

    Best regards,

    Limagito Team

  • 17 Jul

    Convert character set of text file

    Q: Convert character set of text file. I think I need some help here. We connect to a SFTP-server and download 3 files. One of these are a UTF-8 file named Vyymmdd.Thhmmss (i.e. V220627.TT110759). We need to download all 3 files, and convert the UTF-8 file to ISO-8859-1. I have found this article: https://limagito.com/text-character-encoding-conversion/

    And edited like this : psChangeTxtEncodingExt(psFilePath + psFileName, ctOutputpath + psFileName, 65001, 28591, True)

    Runtime Log says the file was successfully converted. But if I open the file in Notepad++ and click the “Encoding” option on the menu, it highlights UTF-8.

    A: In version v2022.7.17.0 we added some extra functions to help you convert the character set of  text files:

    Function psChangeTxtEncodingCk(Source, Destination: String; SrcCharset, DstCharset: String; WriteBOM: Boolean; ErrorAction: Integer): Boolean;

    Do not use this function when Source and Destination file are the same, use psChangeTxtEncodingCkExt instead.

    • ErrorAction: Controls how errors are handled. When a character in the input data cannot be converted to the target charset, the action taken is controlled by this property.
      The possible settings are:
      (0) drop the error characters,
      (1) substitute the data set by a ?
      (2) convert to a hex-escaped string (&#xXXXX)
      (3) RESERVED
      (4) RESERVED
      (5) RESERVED
      (6) RESERVED
      (7) Pass non-convertible characters to the output unchanged.
    • The Source and Destination Charset can be any of the supported encodings listed at Chilkat Supported Character Encodings.

    Function psChangeTxtEncodingCkExt(Source, Destination: String; SrcCharset, DstCharset: String; WriteBOM, WriteFileIfModified: Boolean): String;

      • WriteFileIfModified: writes the contents to a file, but only if it is a new file or if the contents are different than the existing file.
      • WriteBOM: the BOM (also known as a preamble), is emitted for charsets that define a BOM (such as utf-8, utf-16, utf-32, etc.)
      • The Source and Destination Charset can be any of the supported encodings listed at Chilkat Supported Character Encodings.

    #Filetransfer #Filemanagement #Encoding

    If you need any info about this ‘Convert character set’ question, please let us know.

    Best regards,

    Limagito Team

  • 18 Jun

    SMTP Error Message could not be assembled due to error 1

    Q: We had an issue with one of our servers, and had to rebuild it from scratch. When we rebuilt our workflows all seemed to be fine however we are getting the following error when we try to initiate an SMTP workflow.
    6/14/2022 5:03:47 PM SendSMTPMsg Exception: Message could not be assembled due to error 1
    We don’t see any errors on the SMTP server, and this is the same setup we had in place before the previous server failed.
    Can you give us a direction on this? I am not sure what error 1 means, and I am unable to find it in the documentation.

    A: Did you copy/paste some text into the body (or subject) field? Could you clear the body completely and do a test please.

    This is most likely the message contains a character which is not covered by the current charset. If you didn’t set any charset, “iso-8859-1” is used by default.
    Also, please make sure you’ve provided at least one “from” address and at least one “to” address. This could be the reason of the error also.

    For SMTP we also have a CharSet option. In your case I would set it to:   utf-8

    assembled due to error 1

    #SMTP #Filetransfer #Filemanagement

    If you need any info about this ‘assembled due to error 1’ request, please let us know.

    Best regards,

    Limagito Team

1 48 49 50 51 52 53 54 145
SEARCH