Pascal Script

  • 16 Jan

    How to get week number from filename

    Week number from filename

    Q: I have tried to look at your blog and pascal scripts, but have not found what I am looking for, so maybe you could help.

    I would like to rename files with filename starting with a date to year and two digit week number.
    Example: 18-01-2026-different-names-etc.pdf
    New filename: 202603-different-names-etc.pdf

    A: This is possible using our scriptin option

    • Destination Setup, you need an extra Destination:
      • First Destination must be our Pascal Script
      • Second Destination will be your output

    limagito file mover destination setup

    • Add the following Pascal Script in the First Destination, script: link

    limagito file mover week number from filename

    • Enable and add the following File renaming setup in the Second Destination (= your output directory):

    limagito file mover windows folder as destinationlimagito file mover file renaming setup

    • RunTime Log Result:

    limagito file mover runtime log result

    If you need any help about this ‘week number from filename’ question, please let us know.

    Best Regards,

    Limagito Team

    #basic #managedfiletransfer #filetransfer #filemanagement

    By Limagito-Team Pascal Script Rename
  • 21 Nov

    Send email when Number of files in a folder is higher than 10

    Q: I would like to know how in Limagito to Send email when Number of files in a folder is higher than 10. So, count the number of *.xml files in a specific folder, and simply notify when the number is higher than 10.

    A: Yes, this is possible using our scripting option

    • As Source we used our PScript option and added the following script:
      • Do not forget to adjust the Const values
        • ctSourcePath, ctFilter, ctIncludeSubDir and ctFileCount
      • Add the following script
        • If count of files > 10 than this will trigger the On Success Rule Event (psExitCode = 1)
    Var
      tmpCount: Integer;
    Const
      ctSourcePath = 'C:\Test\In_Xml\';
      ctFilter = '*.xml';
      ctIncludeSubDir = True;
      ctFileCount = 10;
    Begin
      psExitCode:= 0;
      // ... add your code here
      tmpCount := psCountFiles(ctSourcePath, ctFilter, ctIncludeSubDir);
      If tmpCount > ctFileCount Then
      Begin
        psLogWrite(1, '', 'File Count: ' + IntToSTr(tmpCount) + ', more than ' + IntToStr(ctFileCount));
        psExitCode := 1;
      End;
    End.

    limagito file mover number of files in a folder

    • Next add the On Success Rule Event

    limagito filemover on success rule event

    • Do not forget to enable the option ‘Enable On Success Events for LimagitoX temporary Files’.
      • This is needed because in this case we don’t have any Destination.

    limagito file mover on success rule event options

    • Result email:

    Send email when Number of files in a folder is higher than 10

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

    Best Regards,

    Limagito Team

    #managedfiletransfer #filetransfer #filemanagement

     

     

  • 04 Oct

    How to move directories by sending an xml to a watch folder

    How to move directories by sending an xml to a watch folder

    Q: I want to move directories recusivly from one volume to another, by sending an xml to a watch folder.

    <Move>
    <Dir Src=”C:\Test\Label\In Dest=”C:\Test\Label\Out/>
    </Move>
    This moves all files and subdirectories from the source to destination, every time I drop a new file into the processing folder. Each xml will contain one entry (Src and Dest). When a xml file is successfully processed it should go to a ‘backup’ folder.
    A: Yes, this should be possible using our Pascal Script option. We’ll read the ‘Scr’ and ‘Dest’ value from the xml, the function and other settings need to be done within our File Mover. Both Src and Dest should be Windows folders or shares. We added an option that will move invalid xml files to an ‘error’ folder.
    • We used the following test folder structure:
    limagito file mover move directories by sending an xml
    • The Xml processing folder contains two subfolders:
      • Backup: when a xml file is successfully processed it should go to a ‘backup’ subfolder
      • Error: invalid xml files will be moved to this ‘error’ subfolder

    limagito file mover move directories by sending an xml

    • Source Setup:
      • Variable %VSA ( Variable String A ) will be set using our Pascal Script option

    limagito file mover windows folder as source

    • Destination Setup:
      • Variable %VSB ( Variable String B )will be set using our Pascal Script option

    limagito file mover windows folder as destination setup

    • Open our Pascal Script option:

    limagito filemover pascal script option

    • Enable and add the following ‘On Rule Begin’ Pascal Script:
      • You can download the script here
      • Do not forget to adjust the Const values
        • ctXmlPath: Path where we need to look for xml files
        • ctXmlErrorPath: Path where we will move invalid xml files to
        • ctRoot, ctChild, ctAttrSrc, ctAttrDest: Where do we need to look in the xml files to find ‘Src’ and ‘Dest’ values.

    limagito file mover on rule begin pascal script

    • Enable and add the following ‘On Rule End’ Pascal Script:
      • You can download the script here
      • Do not forget to adjust the Const values
        • ctXmlBackupPath: Path where successfully processed xml files are moved to

    limagito file mover on rule en pascal script

    • RunTime Log Result:
      • We found a valid ‘xml_processor.xml’ file containing ‘C:\Test\Label\In’ as Src and ‘C:\Test\Label\Out’ as Dest

    limagito file mover runtime log result

    If you need any help about this ‘move directories by sending an xml’ request, please let us know.

    Best Regards,

    Limagito Team

    #xml #managedfiletransfer #filetransfer #filemanagement

1 2 3 4 32
SEARCH