File Mover Blog

February 10, 2023

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 :


Should be replaced with


And the string


Should be replaced with


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


  tmpFileIn, tmpFileOut: String;
  tmpList: TStringList;
  ctOutputPath = 'C:\Test\Out_Txt\';
  // Init var
  psExitCode:= 0;
  tmpFileIn := psFilePath + psFileName;
  tmpFileOut := ctOutputPath + psFileName; 
  // ... add your code here
  tmpList := TStringList.Create;
      tmpList.Text := psStringReplace(tmpList.Text, ';19;18;;', ';36;35;;');
      tmpList.Text := psStringReplace(tmpList.Text, ';21;21;;', ';37;37;;');
      If psSaveTxt2File(tmpList.Text, ctOutputPath + psFileName, 'ISO-8859-1', False) Then
        psExitCode := 1;
        psLogWrite(1, '', 'SaveToFile ' + tmpFileOut + ' Successful');    
        psLogWrite(1, '', 'SaveToFile ' + tmpFileOut + ' Error');
      psLogWrite(1, '', 'LoadFromFile ' + tmpFileIn + ' Exception');

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

By Limagito-Team Pascal Script WIN XLS/CSV , Share: