Pascal Script

  • 08 Dec

    How to email a list of deleted files

    How to email a list of deleted files

    Q: I want to email a list of deleted files on a weekly base. Is this possible with Limagito File Mover.

    A: You could use our ‘Logging to File’ option but in this case the customer wanted a custom list file so we used our scripting option.

    • First you’ll need to setup your delete Rule. We used a Windows Folder as Source:

    limagito file mover Windows folder as source

    • Set Function To ‘Delete Files’:

    limagito file mover list of deleted files

    • Open our ‘Rule Events’ option:

    limagito file mover rule events option

    • Enable ‘On Success’ Event and add the following Pascal Scriptt:
      • do not forget to adjust the ctOutputFile Const
        • We used ‘C:\Test\FileToSend.txt’
    Var
      tmpList: TStringList;
    Const
      ctOutputFile = 'C:\Test\FileToSend.txt';
    Begin
      psExitCode:= 1;
      // ... add your code here
      tmpList := TStringList.Create;
      Try
        Try
          If FileExists(ctOutputFile) Then
            tmpList.LoadFromFile(ctOutputFile)
          Else
            tmpList.Add('Files deleted since ' + FormatDateTime('d mmmm yyyy', Now));          
          // Add Info
          tmpList.Add(FormatDateTime('YYYY/MM/DD HH:NN:SS', Now) + ' Deleted File: ' + psFilePath + psFileName);
          // Save
          tmpList.SaveToFile(ctOutputFile)          
        Except
          psLogWrite(1, '', 'Could not adjust file: ' + ctOutputFile); 
        End;
      Finally
        tmpList.Free;
      End;
    End.

    limagito file mover list of deleted files

    • Next add a second Rule which you’ll trigger once a week. Let the second Rule ‘Move’ the create file ‘C:\Test\FileToSend.txt’ (previously defined inthe script of the delete Rule as ctOutputFile) and use SMTP (email) as Destination.
      • We would use our schedule option to move this listing file once a week
        • The example is set to every Monday at 6:00 AM

    limagito file mover schedule option

    If you need any help with this “list of deleted files” question, please let us know.

    Best Regards,

    Limagito Team

    #managedfiletransfer #filetransfer #filemanagement

  • 06 Dec

    How to add a record to a csv file

    How to add a record to a csv file

    Q: I have a job which is processed through another bit of software, I get 1 file in and at the end of the process, I can have over 100 data files.

    I need to add a record to the start of each file with the same structure, the fields can be empty but I do need to populate 2 of the fields.

    • Sequence fields needs to be 000000
    • Outname fields needs to be the name of the data file

    I then need to add a record at the end of the file but only 1 field needs to be populated

    • Sequence = 999999

    Is this achievable in Limagito? I can do this within the software that processes the data but it will be a very long process to set up.

    A: This should be possible using our scripting option.

    • We used a Windows folder as Source:

    limagito file mover windows folder as source

    • We added the following Include Filename filter because we want to be sure we only are going to handle csv files:

    limagito filemover filename filter

    • As Destination we used our PScript (Pascal Script) option:

    limagito filemover destination setup

    • Please add the following Pascal Script
      • Please add the following script: link
      • Do not forget to adjust the ctOutputPath ( path must end with a \ )
        • This is the path where the adjusted csv files will be saved

    limagito file mover add a record to a csv file

    • Example content of csv source file before changes:

    limagito filemover csv example file

    • Example content of csv destination file after changes:

    limagito file mover example csv file

    Feedback customer:

    You are an absolute legend. Thank you very much

    If you need any help with this “add a record to a csv file” question, please let us know.

    Best Regards,

    Limagito Team

    #csv #managedfiletransfer #filetransfer #filemanagement

    By Limagito-Team CSV Pascal Script ,
  • 11 Oct

    How to move two linked files at the same time

    How to move two linked files at the same time

    Q: I have a particular issue and maybe you have an answer? I need to build in a delay in the moving of files. Each time it involves 2 linked files that must be moved at the same time, the next move of 2 files may only occur when the schedule is triggered again. It is about O and R in filename files. It happens that several are created in 1 minute. However, I want 1 set of O and R files per running move rule to be moved. Do you have a magnificent solution for this that I can implement in the rule?

    limagito filemover move two linked files

     

    A: This should be possible using our Pascal Script option. Please have a look at the following blog article.

    • We used a Windows folder as Source:

    limagito file mover windows folder as source

    • Since we should copy only one set of files (linked O and R files) during each scan, we adjusted the ‘Max. Files processed in One Scan’ to 2.

    limagito file mover maximum files processed in one scan

    • Open our Pascal Script option:

    limagito file mover pascal script option

    • Enable and Add the following ‘On Rule Begin’ Pascal Script:
      • The scripts are available at the following link

    limagito file mover pascal script setup

    • Enable and Add the following ‘On Rule Begin’ Pascal Script:

    limagito file mover move two linked files pascal script

    • The Function is set to ‘Move’:

    limagito file mover function setup

    • As Destination we also used a Windows folder:

    limagito file mover destination setup

    limagito file mover windows folder as destination

     

    If you need any help with this ‘move two linked files’ question, please let us know.

    Best Regards,

    Limagito Team

    #managedfiletransfer #filetransfer #filemanagement

1 2 3 4 29
SEARCH