Q: I want to be able to Find in File text content. Is this possible? For example, if the file contain a string in the file content, than do an operation. Is it possible in Limagito or we can only do something with the file name?
In attachment, you will find folders and files example.
– If we find the string ST^832^ then we need to move the file in the folder « Price »
– If we find the string ST^810^ then we need to move the file in the folder « Invoice »
So, the process should do this :
– Move the files !EDIFile.Exaple1 and !EDIFile.Example2 in folder « Price »
– Move the file ASSET.Example in folder « Invoice »
A: Yes this is possible using a custom script which we create for you. I’ve added some screenshots to help you.
- Source is a Windows folder:
- Open ‘Pascal Script’ Setup:
- Enable and add the following ‘On Destination’ Pascal Script:
Var tmpFile: String; tmpList: TStringList; Const ctInvoiceSearch = 'ST^810^'; ctPriceSearch = 'ST^832^'; ctInvoiceSubDir = 'Invoice'; ctPriceSubDir = 'Price'; Begin psVSA := ''; psExitCode:= 0; // ... add your code here tmpFile := psFilePath + psFileName; tmpList := TStringList.Create; Try Try tmpList.LoadFromFile(tmpFile); // Check Invoice If pos(ctInvoiceSearch, tmpList.Text) <> 0 Then Begin psVSA := ctInvoiceSubDir; psExitCode := 1; psLogWrite(1, '', 'Destination SubDir: ' + ctInvoiceSubDir + ' for ' +tmpFile); End; // Check Price If pos(ctPriceSearch, tmpList.Text) <> 0 Then Begin psVSA := ctPriceSubDir; psExitCode := 1; psLogWrite(1, '', 'Destination SubDir: ' + ctPriceSubDir + ' for ' + tmpFile); End; // Nothing was Found If psVSA = '' Then Begin psLogWrite(1, '', 'Destination SubDir Unknown for ' + tmpFile); End; Except psLogWrite(1, '', 'Error loading ' + tmpFile); End; Finally tmpList.Free; End; End.
- Set Function to ‘Move Files’:
- Add ‘WIN’ as Destination
- Select your Destination Directory:
- Adjust the default ‘Create Subdir, option’ to: %VSA\%SFS
The reason you need to change this is because we’ want to use information from the previous Pascal Script to select the correct Subdirectory. In this example it will be ‘Price’ or ‘Invoice’.
- RunTime Log Result:
#FileTransfer
Best regards,
Limagito Team