Pascal Script

  • 28 May

    Create an empty file named done.txt as all the files have been moved

    Q: We are using your software for some simple file moving automation. We find it very reliable and we would like to convert our existing CMD and ps scripts to Limagito rules. We have a script which performs the following steps:

    • Copy a directory and its contents from an FTP source only if the directory name matches a certain pattern (LQJ_yyyymmdd) > OK
    • Transfer the contents of the directory to an FTP destination in the folder /Replica/yyyymmdd/LQJ > OK
    • Create an empty file named done.txt as soon as all the files have been moved to the destination (step 2) in the FTP folder /Replica/yyymmdd

    Could you give me a hint about how to perform the last step?

    A: This is possible using some Pascal Script we created for you.

    Please open the Pascal Script setup:

    limagito file mover pascal script

    • Enable and Add the following ‘On Rule Begin’ Pascal Script. The result of psVSB will be used as parameter (%VSB) in the directory filter setup.
    Begin
      psExitCode:= 1;
      // ... add your code here
      psVSA := FormatDateTime('YYYYMMDD', Now);
      psVSB := '*_' + psVSA + ';' + '*\*_' + psVSA + '\*';
      //
      psLogWrite(1, '', psVSB);
    End.

    limagito file mover on rule begin pascal script

    • Enable and add the following ‘On Rule End’ Pascal Script. This script will create the Done.txt file ‘On Rule End’ when all files were transferred successfully. Don’t forget to adjust the ctDonePath ( must end with a \ ).
    Var
      tmpList: TStringList;
      tmpFile: String;
    Const
      ctDonePath = 'C:\Test\Pressor\Replica\';
    Begin
      psExitCode:= 0;
      tmpFile := ctDonePath + psVSA + '\Done.txt';
      // ... add your code here
      If (psCurrentFilesSrcError = 0) And (psCurrentFilesDstError = 0) Then
      Begin
        tmpList := TStringList.Create;
        Try
          tmpList.Text := 'Dummy Content';
          Try
            psCreatePath(ctDonePath + psVSA);
            tmpList.SaveToFile(tmpFile);
            // Debug
            psLogWrite(1, '', 'Save To File ' + tmpFile + ' Successful');
            // set ExitCode Successful
            psExitCode := 1;
          Except
            psLogWrite(1, '', 'Save To File ' + tmpFile + ' Error');
          End;
        Finally
          tmpList.Free;
        End;
      End
      Else
        psLogWrite(1, '', tmpFile + ' will not be created due to source or desitnation error(s)');
    End.

    limagito file mover on rule end pascal script

    • Directory setup, be sure to enable ‘Include Subdirectories’ and ‘Exclude Basedirectory’:

    limagito file mover directory setup

    • Set Dir Name include filter to:  %VSB

    The value of parameter %VSB will be set in the ‘On Rule Begin’ Pascal Script.

    limagit file mover directory name filter

    • Set Dir Name exclude filter to exclude certain unwanted subfolders:

    limagito file mover directory exclude filter

    • Be sure to allow the use of parameters in the Directory Name filter:

    limagito file mover directory filter

    • Destination setup:

    Limagito file mover destination setup

    limagito file mover win as destination

    limagito file mover windows folder as destination

    #filetransfer #mft #filemanagement

    If you need any info  about this ‘Create an empty file named done’ request, please let us know.

    Best regards,

    Limagito Team

    By Limagito-Team Filters Pascal Script ,
  • 28 May

    Delete all contents of a destination folder before files are moved

    Q: Is there a way to delete all contents of a destination folder before files are moved/not just overwriting them? I am unzipping a large folder with files daily, most files are named the same thing so they can overwrite them. Have a few that are named with dates and times so they just end up staying in the folder.

    A: If the unzip folder is always the same, the following solution could help you. We added a script that will delete all files and subfolders when ‘On Rule Begin’ is triggered. The path you need to use in the script is the one you will use in your UNZIP as Destination setup.

    – Open Pascal Script Setup

    limagito file mover pascal script

    • Enable and Add the following ‘On Rule Begin’ Pascal Script. In this example our Unzip path = C:\Test\Out\UNZIP\

    Don’t forget to adjust the ctOutputPath const, must end with a \

    Const
      ctOutputPath = 'C:\Test\Out\UNZIP\';
    Begin
      psExitCode:= 1;
      // ... add your code here
      psLogWrite(1, '', 'Delete Tree: ' + ctOutputPath);
      psDeleteFiles(ctOutputPath, '*.*');
      psDeleteTree(ctOutputPath, True);
    End.

    Delete all contents of a destination

    #filetransfer #mft #filemanagement

    If you need any info  about this ‘Delete all contents of a destination’ request, please let us know.

    Best regards,

    Limagito Team

    By Limagito-Team Pascal Script WIN ZIP ,
  • 26 May

    Image and sidecar xml workflow question

    Q: We have a new process that backs up and then moves an image file and sidecar xml file into an input directory [folder A] for our automated photo toning software.
    The xml file contains instructions for cropping and has the same name as the image file with the exception of their file extensions, for example 230519_511627666.xml and 230519_511627666.jpg.
    The photo toning software ingests both the .xml and .jpg and attempts to tone the image, but if the .jpg fails it is output to an error folder [B] without being cropped and toned.
    We pick up the errored .jpg from folder B, resize it with other software and drop it to another folder [C].
    We need to then move the .jpg from folder C back to input folder A to try it again, but it requires its corresponding .xml file which can be found in the backup folder [D] be dropped alongside it again to process and tone.
    Is it possible with a Limagito rule to monitor source folder C and if an image file is found, grab the .xml file of the same name from folder D, then drop them both to folder A?
    Hope that makes sense! Thanks, David

    A: Yes, should be possible. We’ll prepare a script for this asap.

    • We created the following directory structure for the test of the script:

    Image and sidecar xml

    • Source is the C folder (resized files):

    Limagito file mover windows as source

    • Filename Include Filter, we only want to scan for jpg files:

    limagito file mover filename include filter

    • Enable and add ‘On Destination’ Pascal Script:

    limagito file mover pascal script

    • Don’t forget to adjust the Path const values:
    var
      tmpFilename: String;
    Const
      // Path must end with a \
      ctBackupPath = 'C:\Test\AJC\D\';
      ctDestinationPath = 'C:\Test\AJC\A\';
    Begin
      psExitCode:= 0;
      tmpFilename := ChangeFileExt(psFileName, '.xml');
      If FileExists(ctBackupPath + tmpFilename) Then
      Begin
        If psCopyFile(ctBackupPath + tmpFilename, ctDestinationPath + tmpFilename, False) Then
        Begin
           psExitCode:= 1;
           psLogWrite(1, '', 'Copy file success of ' + ctBackupPath + tmpFilename + ' to ' + ctDestinationPath + tmpFilename);
        End
        Else
        Begin
          psLogWrite(1, '', 'Copy file error of ' + ctBackupPath + tmpFilename + ' to ' + ctDestinationPath + tmpFilename);
        End;
      End
      Else
        psLogWrite(1, '', 'Error, xml file does not exist: ' + ctBackupPath + tmpFilename);
    End.

    limagito file mover pascal script as destination

    Feedback user:

    • Thank you, I’ll try this out and let you know if I have any issues with it. Appreciate the quick response!
    • Just wanted to update, this rule and script appears to work great and I have it in place in our production workflow now, thanks again!

    #filetransfer #mft #filemanagement

    If you need any info  about this ‘Image and sidecar xml workflow question’, please let us know.

    Best regards,

    Limagito Team

     

    By Limagito-Team Image Pascal Script , ,
1 5 6 7 8 9 10 11 26
SEARCH