web stats
Filename verify before processing - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 08-15-2018, 02:52 PM
Mits87 Mits87 is offline
OBX.2 Kenobi
 
Join Date: Nov 2016
Posts: 55
Mits87 is on a distinguished road
Default Error in filemove

I am reading a delimited file and using batch processing option. The rule is the filename should be in format of Firstname_lastname_PatientID.txt so i am using regular expression to check if filename. if the file does not have correct naming format i need to move them to C:\error directory with Firstname_lastname_PatientID_error.txt. (the file name will have actually name and ID so it will be different everytime)

Below is my code in postprocess script

Code:
var originalfile = sourceMap.get('originalFilename');
var str= originalfile;
var hasDuplicates = (/[A-za-z]+_[A-za-z]+_[0-9]*.txt/).test(str);
if (hasDuplicates ==false) 
{
var src = 'C:\\'+ originalfile ;
var dest = 'C:\\Error\\' + originalfile;
logger.info('src is :' + src);
logger.info('Dest is :' + dest);
Packages.org.apache.commons.io.FileUtils.moveFile(src,dest);	
}
The error i get is
Code:
Can't find method org.apache.commons.io.FileUtils.moveFile(org.mozilla.javascript.ConsString,org.mozilla.javascript.ConsString).
I am new in scripting/programming so this if you can point my mistake that would be great.

Also if postprocess is not the best way to use can you point me to right direction.

Last edited by Mits87; 08-16-2018 at 08:08 AM. Reason: Found partial solution for my issue
Reply With Quote
  #2  
Old 09-04-2018, 01:08 PM
bbushelle bbushelle is offline
Mirth Newb
 
Join Date: Jul 2015
Location: Carmel, IN
Posts: 7
bbushelle is on a distinguished road
Default

FileUtils.moveFile expects Java file type. Try:

Code:
Packages.org.apache.commons.io.FileUtils.moveFile(new Packages.java.io.File(src),new Packages.java.io.File(dest));
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 11:43 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation