• 11 Jul

    Generate an xml on output with the same name as the input filename

    Q: I was wondering if Limagito File Mover can generate an xml on output with the same name as the input filename.

    A: Yes this is possible. In this case we’ll add a second Destination. This ‘Pascal Script’ Destination will create the Xml file. It will only generate this xml if the first Destination succeeds.

    1.You can use any Source. In our example we used a Windows Folder.

    2.We only want write the Xml file if the first Destination Succeeds. Therefore we have to select ‘Destination Memory & Exit Cyclus On Error’ as Destination Option in the Function Setup.

    Limagito File Mover Function Setup

    3. Add Pascal Script (PScript) as Second Destination

    Limagito File Mover Pascal Script as Destination

    4. Pascal Script Destination Setup

    We received the following example xml from the user (but we can generate other xml structures too):

    <?xml version=”1.0″ encoding=”iso-8859-1″?>

    We created the following Pascal Script which will generate the xml file. Please don’t forget to adjust the ‘ctOutputPath’ Const which will be different in your case. In our example we’ll create the xml file in: ‘C:\Test\Out\’.

    Limagito File Mover generate xml on output

      tmpFileExt: String;
      tmpFileName, tmpFileNameNoExt: String;
      tmpXml: TStringList;
      ctOutputPath = 'C:\Test\Out\'; // must end with a \
      psExitCode:= 0;
      tmpFileExt := ExtractFileExt(psFileName);
      tmpFilenameNoExt := psStringReplace(psFileName, tmpFileExt, '');
      tmpFileName := tmpFileNameNoExt + '.xml';
      // Create XML
      tmpXml := TStringList.Create;
        tmpXml.Add('<!--?xml version="1.0" encoding="iso-8859-1"?-->')
        tmpXml.Add('' + tmpFileNameNoExt + '');
        tmpXml.Add('' + psFileName + '');
        // Save to File  
          tmpXml.SaveToFile(ctOutputPath + tmpFileName);
          psExitCode := 1;   
          psLogWrite(1, '', 'SaveToFile Error, File: ' + ctOutputPath + tmpFileName);

    5.RunTimeLog Result:

    Limagito File Mover RunTime Log

    6. Generated Xml on Output:

    Limagito File Mover generate xml on output


    If you need any info about this new ‘Generate an xml on output’ option, please let us know.

    Best regards,

    Limagito Team

    By Limagito-Team XML ,