How-to

  • 28 Sep

    How to wrap any lines longer than say 80 characters

    How to wrap any lines longer than say 80 characters

    Q: Is there a way when moving a text file to wrap any lines longer than say 80 characters?

    A: Yes this possible using the following Pascal Script as Destination

    • Add our Pascal Script option in your Destination setup
      • Don’t forget to adjust the  ctOutputPath  Const value.

    limagito file mover wrap any lines longer than

    Var
      iList: Integer;
      tmpEntry, tmpStrip: String;
      tmpFileIn, tmpFileOut: String;
      tmpListIn, tmpListOut: TStringList;  
    Const
      // Should be different than the Source path, must end with a \
      ctWordWrap = 80;
      ctOutputPath = 'C:\Test\Out_TXT\'; 
    Begin
      psExitCode := 0;
      tmpFileIn := psFilePath + psFileName;
      tmpFileOut := ctOutputPath + psFileName;
      // ... add your code here
      tmpListIn := TStringList.Create;
      tmpListOut := TStringList.Create;
      Try
        Try
          tmpListIn.LoadFromFile(tmpFileIn);
          // Iterate
          For iList := 0 to (tmpListIn.Count-1) Do
          Begin
            tmpEntry := tmpListIn.Strings[iList];
            if Length(tmpEntry) > ctWordWrap Then
            Begin
              Repeat
                tmpStrip := Copy(tmpEntry, 1, ctWordWrap);   
                tmpListOut.Add(tmpStrip);
                tmpEntry := Copy(tmpEntry, ctWordWrap+1, length(tmpEntry)-ctWordWrap);
                If Length(tmpEntry) <= ctWordWrap Then
                  tmpListOut.Add(tmpEntry);   
              Until Length(tmpEntry) <= ctWordWrap;  
            End
            Else
              tmpListOut.Add(tmpEntry); 
          End;
        Except
          psLogWrite(1, '', 'Error handling ' + tmpFileIn); 
        End;
        // Save Result
        Try
          psLogWrite(1, '', 'Saving ' + tmpFileOut);
          tmpListOut.SaveToFile(tmpFileOut);
          // Set Result to Successful
          psExitCode := 1;
        Except
          psLogWrite(1, '', 'Error saving ' + tmpFileOut); 
        End;    
      Finally
        tmpListIn.Free;
        tmpListOut.Free;
      End;    
    End.

     

    If you need any help about this ‘wrap any lines longer than’ request, please let us know.

    Best Regards,

    Limagito Team

    #managedfiletransfer #filetransfer #filemanagement

  • 28 Aug

    How to convert UTF8-BOM to UTF8 by stripping the three-byte BOM

    Q: Can LimagitoX convert UTF8-BOM to UTF8 by stripping the three-byte BOM (EF BB BF) from files?

    A: Yes, please add a PScript as Destination:

    • Add the following script: link

    limagito file mover stripping the three-byte BOM

    Feedback customer:

    Thank you for your prompt response. Success! Thank you for your help.

    If you need any help about this ‘stripping the three-byte BOM’, please let us know.

    Best Regards,

    Limagito Team

    #managedfiletransfer #filetransfer #filemanagement

  • 08 Jun

    How to rename a file using its parent folder name

    How to rename a file using its parent folder name

    Q: When working with Limagito, we were wondering if you had recommendations on how to handle this scenario.

    1. We would like to transfer files from a directory lets call it E:\Orignal Location. I have two folders and files under this directory below.
      • Under E:\Orignal Location\UNIT_1_4.1.2025\history.xml
      • Under E:\Orignal Location\UNIT_2_5.1.2025\history.xml
    2. We would like to rename the history.xml to the parent folder name, highlighted above, while moving it to final file location E:\Final Location
    3. The file result we are looking for is for two files in the location  E:\Final Location:
      • UNIT_1_4.1.2025.xml
      • UNIT_2_5.1.2025.xml

    How would you recommend configuring, or is it possible to configure the renaming since the value we want to rename is the parent name, while also moving the file to a new location with Limagito.

    A: We did a test with pdf files instead of xml, but the result would be the same.

    In your case,  E:\Orignal Location\ would be the WIN Source

    Our Directory Filter setup:

    limagito file mover directory filter option

    limagito file mover directory setup

    Destination Setup:

    limagito file mover destination setup

    limagito file mover destination options

    limagito file mover Windows folder as destination

    Please uncheck ‘Create Subdir’ because all files should go to the same folder:

    limagito file mover destination file and directory options

    Enable ‘Rename Files during Copy/Move’

    limagito file mover destination file rename option

    – Add the following file renaming setup:
    RegEx:  (.*)\.(.*)
    Replacement:  %SFS.\2

    limagito file mover destination file rename setup

    – Alternative file renaming setup when you have multiple levels of subfolders:

    • %SFS:?=?: parameter option was added recently
      • %SFS:0=1:
        • 0 > start at the end of the subfolders(s) Var %SFS > %SFS = Source File Subfolder(s)
        • 1 > use the last subfolder part only
    RegEx:  (.*)\.(.*)
    Replacement:  %SFS:0=1:.\2

    limagito file mover file renaming setup

    – RunTime Log result:

    limagito file mover runtime log result

    If you need any help with this question, please let us know.

    Best Regards,

    Limagito Team

    #managedfiletransfer #filetransfer #filemanagement

    By Limagito-Team How-to Rename , ,
1 2 3 4 5 10
SEARCH