WIN

  • 10 Feb

    Move and change content of a txt-file

    Q: Hello Limagito, Now I need your help again…

    I got a TXT-file delivered from my customer with approximately 250 rows.

    In the txt file I like “search and replace” a text string :

    ;19;18;;

    Should be replaced with

    ;36;35;;

    And the string

    ;21;21;;

    Should be replaced with

    ;37;37;;

    I also tried to set the powershell exe file in the field for Application name (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe)

    Is there any other way?

    A: Yes there is, we can do this easily with our Pascal Script so no need for external scripts if you want.

    In our example we’ll use a Windows folder as Source:

    Limagito File Mover WIN as Source

    We only want to handle .txt file so we added the following Filename Include Filter:

    Limagito File Mover Include Filename Filter

    As Destination we added a Pascal Script. This script will does the work you requested.

    Limagito File Mover Pascal Script as Destination

    • Adjust ctOutputPath > must end with a \
    • Encoding of destination text file can be adjusted

     

    Var
      tmpFileIn, tmpFileOut: String;
      tmpList: TStringList;
    Const
      ctOutputPath = 'C:\Test\Out_Txt\';
    Begin
      // Init var
      psExitCode:= 0;
      tmpFileIn := psFilePath + psFileName;
      tmpFileOut := ctOutputPath + psFileName; 
      // ... add your code here
      tmpList := TStringList.Create;
      Try
        Try
          tmpList.LoadFromFile(tmpFileIn);
          tmpList.Text := psStringReplace(tmpList.Text, ';19;18;;', ';36;35;;');
          tmpList.Text := psStringReplace(tmpList.Text, ';21;21;;', ';37;37;;');
          // https://docs.microsoft.com/nl-be/windows/win32/intl/code-page-identifiers
          If psSaveTxt2File(tmpList.Text, ctOutputPath + psFileName, 'ISO-8859-1', False) Then
          Begin
            psExitCode := 1;
            psLogWrite(1, '', 'SaveToFile ' + tmpFileOut + ' Successful');    
          End
          Else
            psLogWrite(1, '', 'SaveToFile ' + tmpFileOut + ' Error');
        Except
          psLogWrite(1, '', 'LoadFromFile ' + tmpFileIn + ' Exception');
        End;
      Finally
        tmpList.Free;
      End;  
    End.

    Limagito File Mover Pascal Script as Destination

    Feedback Customer:

    As always you save the day! The Pascal script did my work easily. Some day I have to learn more about pascal!

    I cheat some in powershell and some visual basic, but this stuff is powerful!

    By the way, it only worked in the newer version of Limagito (I still have some workflows in the old version)

    Thank you for help, quick and accurate, as always!

    #FileTransfer #Encoding

    If you need any info about this ‘change content of a txt-file’ request, please let us know.

    Best regards,

    Limagito Team

  • 09 Feb

    Error code 1265 when Trying to run rules on remote devices via DNS name

    Q: I am having the following error:

    Exception: Error trying to create file handle for ‘example of filename with DNS Source Path’ Error code 1265

    There is no error when using the IP address, but we use rotating ip addresses so that is not a viable solution, could you help me troubleshoot this?

    Error Code 1265

    A: Error codes when using WIN as Source or Destination are Operating System Errors. We are using the same function and procedures as the Windows File Explorer does. This is the first time we received feedback of error code 1265. A Google search returns over 5.000.000 hits.

    Although the ‘Logon As’ user of the Limagito Service was set correctly we could not search in this folder. It did not show any subfolders or files using our ‘Explorer’ in the WIN as Source setup screen.

    Error Code 1265

    We solved the issue by adding the Source Path and an appropriate User Account in our Network Drive option.

    Tools Menu Time > Network Drive

    Network Drive Setup

    #FileTransfer #1265

    If you need any info about this ‘Error Code 1265’, please let us know.

    Best regards,

    Limagito Team

    By Limagito-Team WIN
  • 29 May

    Specify to copy the second most recent file

    Q: Can you recommend any way using Limagito, that we can specify to copy the second most recent file, i.e. at midnight today, copy the file from midnight yesterday? So the creation of a new file in the folder would trigger the copying of the previous file.
    A client of ours has recently licensed Limagito. The primary use is for transferring text files from an equipment server to a historian server, where it can be processed. We have one use case that is a bit tricky, and we are hoping that you can help with it. The source equipment produces an audit trail text file, which captures changes to the system on a continuous basis. The equipment creates the file every 24 hours, at midnight. Until now, we had been copying this file at midnight, to transfer for processing. The rule we use identifies when a new file is created, and copies this new file. We assumed that the file held the audit trail records for the previous 24 hour. But what is actually the case is that the equipment creates the file at midnight, and then continuously writes to the file for the next 24 hours, and creates a new (blank) file again the next midnight. So the files that we were copying were blank, or only held a few lines of data.
    So a little bit more info. Our client has previously been using different file mover software. They have only recently licensed Limagito. So currently, we are using that different software, but because they now have a Limagito license, we want to use Limagito instead,
    So currently, we have a rule set up (in the other software) which will detect when a new file is added/created in the source folder, and copy that file to the destination folder. So to answer your question, the equipment creates a new file in the source folder at midnight, which is initially blank, but it will write to that file at regular intervals for the subsequent 24 hours. But yes, as you say, we do a copy when the file appears for the first time. So the rule we use monitors the folder for new files, and copies a new file when it appears. What we want to do, is copy the file that was created 24 hours ago.

    A: In this case we could trigger the rule at for example 5 minutes past midnight and use a ‘File Date Include Filter’ of older than 1 day.

    • Please disable the Scan Timers in the ‘Schedule’ Setup:

    Limagito File Mover Disable Timers

    • Enable ‘Use Scheduler’ and Add the following ‘5 minutes past midnight’ schedule:

    Limagito File Mover Scheduler

    Limagito File Mover Once a day schedule

    • Because we are using a ‘Once a day’ trigger it is very important not to enable the ‘Stabilized File Check’ option. The reason is that this option needs at least two triggers because it needs to check if a file size is growing between triggers/scans or not.

    Limagito File Mover Stabilized file check

    • Add the following ‘File Date Include’ filter. Be sure to enable ‘Data Relative’ as File Date Filter Reference.

    Limagito File Mover copy the second most recent file

     

    #Filetransfer #Filemanagement

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

    Best regards,

    Limagito Team

1 2 3 4 5 6 9
SEARCH