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:
- 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.
- 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.
- Directory setup, be sure to enable ‘Include Subdirectories’ and ‘Exclude Basedirectory’:
- Set Dir Name include filter to: %VSB
The value of parameter %VSB will be set in the ‘On Rule Begin’ Pascal Script.
- Set Dir Name exclude filter to exclude certain unwanted subfolders:
- Be sure to allow the use of parameters in the Directory Name filter:
- Destination setup:
#filetransfer #mft #filemanagement