Announcement

Collapse
No announcement yet.

filter by filename

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • filter by filename

    hi,

    I'm not very good at JS but I know what I need.

    I need to filter files coming from my "file"connector.

    If filename "originalfilename" exists in processed folder (all files are moved here after process) then file should be discarded, otherwise it is accepted.

    can someone help me with this.

    thanks
    gianĂ¹

  • #2
    Hi,

    try something like this in your filter.
    please keep in mind that you need to have the full unc path to the file (code example below looks at the C drive where Mirth is installed).


    Code:
    var continue = false;
    var f = new java.io.File("C:\\temp\\testFile.hl7");
    
    if(f.exists() && !f.isDirectory()) { 
    	logger.error("file is there");
            continue = false;
            //do whatever you want.
    } else {
    	logger.error("file is not present");
            continue = true;
    
    }
    
    return continue;
    Last edited by StefanScholte; 05-19-2014, 04:48 AM.
    Stefan

    Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

    Comment


    • #3
      Hi Stefan,
      thanks for answering to my message. You really helped me in finding the right solution.
      follows what i put in my filter and it works.!!!
      thanks agian for your great support....but now I'm into something else another channel and I think i will have to contact you again for more help !!!
      thanks

      var fileA = channelMap.get('originalFilename');
      var f = new java.io.File('D:/processed/'+fileA);

      if(f.exists()) {
      logger.error("file was already processed, this file was discarded");
      return false;
      //do whatever you want.
      } else {
      logger.error("file has been sent to destinations");
      return true;

      }

      Comment

      Working...
      X