Skip to main content
Question

Exclude files from batch

  • 19 November 2012
  • 3 replies
  • 43 views

Hi all is there anyway to setup an exclusion filter on a reader?  I need to run a script about a thousand times with each file in a seperate directory.  Normally I would just put a merge filter on the featuretype (*) and have the reader parameter be rootdir\\**\\*.xml.

 

 

However in this case each directory contains two xml files, one always called metadata.xml and the other is different for every directory.  I only want to read the xml file that changes, not metadata.xml.

 

 

Ideas?
Why not just read everything (if it is not to ridiculous in size) and just expose the relevant format attribute (not sure off the top of my head if it is fme_feature_type or fme_basename for xml)  and test and exclude any features that have Metadata.

 

 

Would that work for your issue?

 

 


What I have working right now is the merge filter on the fme featuretype as a regular expression.

 

 

This is adding a not insginificant amount of time by reading in the unecessary files and I was hoping there is an alternate solution
Without wanting to sound like a broken record by repeating the same answer on this thread too the master and slave approach outlined here (http://fmepedia.safe.com/AnswersQuestionDetail?id=906a0000000ce3vAAA) could also work in this scenario if you were prepared to have 2 workspaces to do the job?

 

 

I'm not aware of a way to restrict or create a name exception other than writing a batch file to first copy all the files you want to a new folder structure (without the metadata.xml files), then call FME on the next command line and then delete the copied data as the last step.

 

 

Anyway, in this case you could use the Directory and File Path Reader to read your top level folder and all containing xml file locations not the actual files. So still rootdir\\**\\*.xml. Then each feature will have an attribute windows_path = c:\\folder\\folder\\1.xml and c:\\folder\\folder\\metadata.xml. Use the FilenamePartExtractor to get the filename into an attribute and then test for metadata.xml and throw away those features, then send the path to the XML you are interested in to the workspace that processes it using the WorkspaceRunner. This would assume a batch process dealing with 1 xml file at a time. You could alternatively concatenate all the files you want to read into one long string and pass that across to the slave workspace as its input list of files to read in one go in the required structure, so:

 

 

C:\\folder\\folde\\1.xml,C:\\folder\\folde\\2.xml,C:\\folder\\folde\\3.xml

 

 

Hope that helps

 

 

 

 


Reply