File Mover Blog

  • 11 Aug

    How to send zpl file to Zebra printer using Limagito file mover

    Q: How to send zpl file to Zebra printer. Do you have a solution in Limagito to send Zpl files to a printer? Zpl is a standard language for label printers.
    A: On request we added an option in Limagito File Mover v2023.8.10.0. The customer did some successful tests. These new options should be able to send other Zpl like type of files (EPL,..) to printers too.

    • In our example we used a Windows folder as Source, searching for zpl files:

    limagito file mover windows folder as source

    • We enabled ‘Exclude Files In Use’ because we don’t want to touch source .zpl file that are still being created:

    limagito file mover exclude files in use

    • Please set the Filename Include filter to *.zpl because we only need this type of files:

    limagito file mover filename include filter

    • Our Rule will be triggered every 30 seconds using a scan timer (Schedule Setup button):

    limagito file mover scan timer setup

    • As function we used ‘Move’ because after a successful print we want to delete the source .zpl file:

    limagito file mover function setup

    • As Destination we are going to use a Script:

    limagito file mover as Destination

    Var
      iList: Integer;
      tmpInfo, tmpFile, tmpString: String;
      tmpList: TStringList;
    Begin
      psExitCode:= 0;
      // ... add your code here
      tmpFile := psFilePath + psFileName;
      // Do Send
      tmpList := TStringList.Create;
      Try
        tmpList.CommaText := psGetPrinters;
        If tmpList.Count > 1 Then
        Begin
          For iList := 0 To (tmpList.count-1) Do 
            psLogWrite(1, '', 'Installed printer [' + IntToStr(iList+1) + ']: ' + tmpList.Strings[iList]);
          psLogWrite(1, '', 'Default printer: ' + psGetDefaultPrinter);
        End
        Else
          psLogWrite(1, '', 'No printer installed');        
        psLogWrite(1, '', 'Send file "' + tmpFile + '" to printer');
        Try
          tmpList.Clear;
          tmpList.LoadFromFile(tmpFile);
          If tmpList.Count > 0 Then
          Begin
            tmpString := tmpList.Text;
            // Method 1
            tmpInfo := psPrintRawString(tmpString, '');
            // Method 2
            // tmpInfo := psPrintRawList(tmpList, '');
            // Debug
            If tmpInfo <> '' Then
            Begin
              psLogWrite(1, '', 'Sent to printer error: ' + tmpInfo);
            End Else
            Begin
              psExitCode := 1;  
              psLogWrite(1, '', 'Sent to printer successfully: ' + tmpFile);
            End;
          End
          Else
          psLogWrite(1, '', 'Found empty file: ' + tmpFile);
        Except
          psLogWrite(1, '', 'LoadFromFileError: ' + tmpFile);
        End;
      Finally
        tmpList.Free;
      End;
    End.
    

    The script above will load the content of the .zpl (or other raw type of files) and will send this data to a selected printer.

            // Method 1
            tmpInfo := psPrintRawString(tmpString, ”);

    By default we’ll use the ‘Default’ printer in Windows which means the Zebra printer should be set as Default printer. If you want to use a Zebra printer that is not set to default in Windows you’ll need to add the printer name to the function.

    Suppose the installed Zebra printer name is: My Zebra Printer

            // Method 1
            tmpInfo := psPrintRawString(tmpString, ‘My Zebra Printer’);

    To help you with the printer names, the script will wrote the names in the RunTime log if you trigger the Rule (please check the output of the RunTime log in the screenshot below).

    limagito file mover send zpl file to Zebra printer

    • RunTime Log result:

    limagito runtime log

    If you need any info about this new ‘zpl file to Zebra printer’ option, please let us know.

    #zpl #zebra #filetransfer #filemanagement

    Best regards,

    Limagito Team

    By Limagito-Team Pascal Script Printer , , ,
  • 06 Aug

    New Precondition File Count option added

    We are working on the new Precondition File Count option. Most of the code is ready and tests are being conducted.

    In the past we created quite some file count scripts for customers and that is why we decided to add this as a new Precondition option. The Precondition option is the first step we do after a Rule is triggered and if the preconditions are valid then we’ll continue. At the moment we have 7 Precondition options.

    Limagito file mover precondition file count option

    • We added a couple of possibilities to handle file count (from previous experience with customers):

    lmiagito file mover precondition option

    If you need any info about this ‘File Count’ option, please let us know.

    Best regards,

    Limagito Team

  • 04 Aug

    How to convert xls to tab delimited txt files

    Q: We need to convert xls to tab delimited txt files. The resulting tab delimited txt files should be merged without the header data of the xls file. There will be always three files that need to be merged.

    Example:

    • Accounts_CO-en-us_08042023_009004.xlsx
    • Accounts_NE-en-us_08042023_009007.xlsx
    • Accounts_WY-en-us_08042023_009012.xlsx

    Result should be a txt delimited file:

    • Accounts_WY-en-us_08042023.txt

    A: This is possible using the following setup:

    • Source can be any type. We used a Windows folder as Source

    limagito filemover windows folder as source

    convert xls to tab delimited source files

    • We added *.xlsx as include filename filter:

    limagito file mover include filename filter

    • In this example we used two Destinations
      • First Destination (ID1) is our XLS option which will convert the xlsx file to a tab (#09) delimited txt file
      • Second Destination (ID2) is our Script option and this will:
        • check if the files we need are available
          • we’ll use a filter based on the current date (filter format MMDDYYYY)
          • If we find three files then we are ready to merge, otherwise > error
        • when available will
          • load and merge them, without the header, together
          • save the resulting merged txt file

    limagito file mover destination options

    • XLS Destination Setup:

    Important: The “Destination Directory” in the XLS setup will be used in the second destination (Pascal Script, const ctSearchPath). They both need to be the same., because the script needs to search this “Destination Directory” for converted files.

    limagito file mover xls as destination setup

    limagito file mover xls as destination setup

    • Pascal Script Destination Setup (you’ll need to adjust the ctSearchPath and ctMergedPath):
    Var
      iFilesList, tmpPos: integer;
      tmpFilter, tmpFile, tmpData, tmpOutputName: String;
      tmpFilesList, tmpList: TStringList;  
    Const 
      ctDateMask = 'MMDDYYYY';
      ctSearchPath = 'C:\Test\PVBank\Output\';
      ctMergedPath = 'C:\Test\PVBank\Merged\';  
    Begin
      // Create Var
      tmpList := TStringList.Create;
      Try
        // Init Var
        psExitCode:= -1;
        tmpData := '';
        // Accounts_CO-en-us_08042023_009004
        tmpFilter := FormatDateTime(ctDateMask, Now);
        tmpFilesList := psListFilesEx(ctSearchPath, '*' + tmpFilter + '*', False);
        // Check Qty Files
        If tmpFilesList.Count = 3 Then
        Begin
          psLogWrite(1, '', 'We have found The necessary files using filter: ' + tmpFilter);
          For iFilesList := 0 to (tmpFilesList.Count - 1) Do
          Begin
            Try
              tmpList.Clear;
              tmpFile := tmpFilesList.Strings[iFilesList];
              Try
                tmpList.LoadFromFile(tmpFile);
              Except
                psLogWrite(1, '', 'Exception loading txt file: ' + tmpFile);
              End;
              If tmpList.Count > 0 Then
              Begin
                tmpList.Delete(0);
                tmpData := tmpData + tmpList.Text;
                If iFilesList = (tmpFilesList.Count - 1) Then
                Begin
                  Try
                    tmpList.Text := tmpData;
                    // Save Merged Result
                    tmpFile := ExtractFilename(tmpFile);
                    tmpPos := Pos(tmpFilter, tmpFile);
                    If tmpPos > 1 Then
                      tmpOutputName := Copy(tmpFile, 1, (tmpPos-1) + length('MMDDYYYY')) + '.txt' 
                    Else
                      tmpOutputName := tmpFile;
                    tmpList.SaveToFile(ctMergedPath + tmpOutputName);
                    psExitCode := 1;
                    psLogWrite(1, '', 'Successfully saved merged data to: ' + ctMergedPath + tmpOutputName);
                  Except
                    psExitCode := 0;
                    psLogWrite(1, '', 'Error saving merged data to: ' + ctMergedPath + tmpOutputName);
                    Break;  
                  End;
                End; 
              End
              Else
              Begin
                psExitCode := 0;
                psLogWrite(1, '', 'Error, found empty txt file: ' + tmpFile);
                Break;  
              End; 
            Except
              Break;
            End;
          End;
        End
        Else
        Begin
          psLogWrite(1, '', 'We have not found The necessary files using filter: ' + tmpFilter);  
        End;
      Finally  
        // Free Var
        tmpFilesList.Free;
        tmpList.Free;
      End;  
    End.
    

    limagito file mover pascal script as destination setup

    • XLS as Destination conversion to txt files:

    limagito convert xls to tab delimited output

    • Pascal Script as Destination merged data as text file:

    limagito file mover convert xls to tab delimited merged

    • Content of the merged tab delimited txt files:

    limagito file mover convert xls to tab delimited content

    If you need any info about this ‘convert xls to tab delimited’ question, please let us know.

    Best regards,

    Limagito Team

1 17 18 19 20 21 22 23 135
SEARCH