Parsing Filename as input

Discuss Task Sequences and Scripting related issues.

Postby melvin » Sun Apr 29, 2007 6:58 am

you would have to use the script task to parse the filename.
The script task is available in professional and enterprise editions.

sample code:

import com.hitek.engine.mods.script.Script;

String filename = "test_test2_test3" ;
StringTokenizer st = new StringTokenizer(filename,"_");
int n=0;
while (st.hasMoreTokens())
{
n++;
String varValue = st.nextToken();
// set a user variable value
String varName = "var" + Integer.toString(n);
Script.setVar( varName , varValue );
Script.out("New variable added: " + varName + " , value = " + varValue );
}
melvin
Site Admin
 
Posts: 979
Joined: Thu May 25, 2006 10:20 am
Location: Santa Barbara, california

Postby Tech Support » Mon Apr 30, 2007 7:28 pm

Scripting feature is available in Automize 7.x Professional and Enterprise editions only.

The import statement allows you to use certain functions within Automize like get and set task parameters and variables. Also allows you to run the tasks from with script.
Example:
1) Set task parameter based on filename
2) Run the task
Then loop through steps 1-2 for all files in the folder..

To get file list:

File dir = new File("c:\test");
String[] names = dir.list();
for (int i=0; i<names.length; i++)
{
String filename = names[i];
.....
parse variables from filename and run task etc..
.....

}
Tech Support
Site Admin
 
Posts: 1276
Joined: Thu May 25, 2006 11:12 am


Return to Task Sequences, Chains and Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

cron