// On Rule Begin Pascal Script: Var iList: Integer; tmpResetMem: Boolean; tmpFileList, tmpXmlList: TStringList; tmpInfo, tmpXmlFile: String; Const ctXmlPath = 'C:\Test\Label\Xml\'; ctXmlErrorPath = 'C:\Test\Label\Xml\Error\'; // Must end with a \ ctRoot = 'Move'; ctChild = 'Dir'; ctAttrSrc = 'Src'; ctAttrDest = 'Dest'; Begin psExitCode:= 0; psVSA := ''; psVSB := ''; psVSC := ''; psVIA := 0; // ... add your code here tmpFileList := psListFilesEx(ctXmlPath, '*.xml', False); // Check If Assigned(tmpFileList) Then Begin Try If tmpFileList.Count > 0 Then Begin psLogWrite(1, '', 'Found ' + IntToStr(tmpFileList.Count) + ' Xml file(s)'); // Iterate the xml files we found tmpResetMem := True; For iList := 0 to (tmpFileList.Count - 1) Do Begin tmpXmlFile := tmpFileList.Strings[iList]; If Pos(LowerCase(tmpXmlFile + ';'), LowerCase(psVSD)) = 0 Then Begin tmpResetMem := False; Break; End Else Continue; End; // Check Reset Memory If tmpResetMem Then Begin tmpXmlFile := tmpFileList.Strings[0]; psVSD := ''; End; // Load Xml Content tmpXmlList := TStringList.Create; Try Try tmpXmlList.LoadFromFile(tmpXmlFile); psVSA := psXMLGetAttribute(tmpXmlList.Text, ctRoot, ctChild, ctAttrSrc); psVSB := psXMLGetAttribute(tmpXmlList.Text, ctRoot, ctChild, ctAttrDest); psLogWrite(1, '', 'Src: ' + psVSA + ', Dest: ' + psVSB); Except psLogWrite(1, '', 'Error loading: ' + tmpXmlFile); End; Finally tmpXmlList.Free; End; // Check valid Src and Dest If (psVSA <> '') and (psVSB <> '') Then Begin psExitCode := 1; psVSC := tmpXmlFile; psVSD := psVSD + tmpXmlFile + ';'; psLogWrite(1, '', 'Handle valid Xml File: ' + tmpXmlFile); End Else Begin If psCopyFile(psFilePath + psFileName, ctXmlErrorPath + psFileName, False) Then Begin DeleteFile(psFilePath + psFileName); psLogWrite(1, '', 'Not a valid Xml File: ' + tmpXmlFile + ', moved to ' + ctXmlErrorPath); End Else psLogWrite(1, '', 'Not a valid Xml File: ' + tmpXmlFile + ', error trying to move the file to ' + ctXmlErrorPath); End; End Else Begin psVSD := ''; End; Finally tmpFileList.Free; End; End; End. // On Rule End Pascal Script: Var tmpFilename: String; Const ctXmlBackupPath = 'C:\Test\Label\Xml\Backup\'; // Must end with a \ Begin psExitCode:= 1; // psVSC contains the Xml file we are processing If (psVSC <> '') And (psCurrentFilesSrcError = 0) And (psCurrentFilesDstError = 0) Then Begin tmpFilename := ExtractFileName(psVSC); psVSD := psStringReplace(psVSD, psVSC + ';', ''); If psCopyFile(psVSC, ctXmlBackupPath + tmpFilename, False) Then Begin DeleteFile(psVSC); psLogWrite(1, '', psVSC + ', moved to ' + ctXmlBackupPath) End Else psLogWrite(1, '', psVSC + ', error could not move the file to ' + ctXmlBackupPath); End; // Debug If psVSD <> '' Then psLogWrite(1, '', 'Content psVSD: ' + psVSD); End.