How to set filters when using the ExportItems command via the CommandLine

Overview

If you want to export items from your project using the CommandLine, you can use the ExportItems function to set a filter to export only the items you want. This article will provide you some examples on how to set the filter's value.

 

Description

In Script mode, CommandLine reads a script file containing a list of commands and executes them. For example in the commandline.sh:

./Talend-Studio-linux-gtk-x86 -nosplash -application org.talend.commandline.CommandLine
-consoleLog -data commandline-workspace scriptFile /tmp/myscript

Example of script file read by the CommandLine:

initRemote http:/ /localhost:8888/org.talend.administrator -ul admin@company.com -up passwd
logonProject -pn myProject
exportItems /tmp/myitems.zip

 

The CommandLine's help for ExportItems will give you this information:

exportItems destination (dir.zip) exports items
-d (--dependencies) include dependencies
-if (--item-filter) filterExpr item filter expression

 

This screenshot provides more details on how to write the filter expression:

commadlinefilterCommandes.png

 

Assume there is one job named TestJob with 2 versions: 0.1 and 0.2.

If you wish to get only the 0.2 version of TestJob, you would use:

talend> exportItems /testFilter.zip -if '(type=process)and(label=TestJob)and(version=lastVersion)'

If you want to export all version of TestJob items, remove the version filter:

talend> exportItems /testFilter.zip -if '(type=process)and(label=TestJob)'

If you want to export the name of job and routines items that start with Test, use:

talend> exportItems /home/ggu/testFilter.zip -if '((type=process)or(type=routines))and(label%Test*)and(version=lastVersion)'

NOTE: There should not be any space between two filters and no space for "and" and "or": otherwise the command won't work.

 

Bookshelf references

You can find more details regarding the Commandline and its operating mode in our On-line documentation:

Operating modes

Script mode

Version History
Revision #:
5 of 5
Last update:
‎05-17-2017 03:18 AM
Updated by:
 
Labels (1)
Tags (1)