At the end of the postInstallActionList I'm executing somefile.cmd . This script generates a text file which contains a list of files which copied to rollback directory. Then I read this file using readFile and put the output in some variable (list variable). When I using showInfo to check the list variable everything looks fine. Then , I'm trying to go over list variable by using the foreach tag in order to extract the real location of these files and to check each one of them if fileIsLocked. Unfortunately the results form foreach are weird. It seems that foreach omitting the and some more characters.

As much as I know fileIsLocked can deal with one file at time and my purpose is to go over all files which copied to the rollback directory.

Is there any option that foreach will not omit these characters ? Is there any method/technique to list all files under rollback directory in order to go over them for specific operarion ?


asked 09 Dec '12, 10:49

Ronen's gravatar image

accept rate: 0%

Can you paste an example of output and the code using in the foreach?


answered 09 Dec '12, 13:36

juanjo's gravatar image

juanjo ♦♦
accept rate: 23%

The <foreach> action should be used to iterate over lists generated by InstallBuilder. The issue you may be facing is with \, " or space characters.

If you are generating a list of files where each line is a new file name, <foreach> is not the best way to go. You can use <while> and regular expressions to parse this (and most) formats of data:

<!-- remove any trailing and leading newlines/spaces --> <stringModify> <text>list_of_files</text> <variable>${list_of_files}</variable> </stringModify> <!-- loop while there are any files left -- <while> <conditionRuleList> <compareTextLength> <length>0</length> <logic>greater</logic> <text>${list_of_files}</text> </compareTextLength> </conditionRuleList> <actionList> <!-- check if there are more entries; if so, use regexp to extract current and remaining items, otherwise set current file to the last line and set list_of_files to empty --> <if> <actionList> <setInstallerVariableFromRegEx> <name>current_file</name> <pattern>^(.*?)\n(.*)$</pattern> <substitution>\1</substitution> <text>${list_of_files}</text> </setInstallerVariableFromRegEx> <setInstallerVariableFromRegEx> <name>list_of_files</name> <pattern>^(.*?)\n(.*)$</pattern> <substitution>\2</substitution> <text>${list_of_files}</text> </setInstallerVariableFromRegEx> </actionList> <conditionRuleList> <regExMatch> <logic>matches</logic> <pattern>^(.*?)\n(.*)$</pattern> <text>${list_of_files}</text> </regExMatch> </conditionRuleList> <elseActionList> <setInstallerVariable> <name>current_file</name> <value>${list_of_files}</value> </setInstallerVariable> <setInstallerVariable> <name>list_of_files</name> <value></value> </setInstallerVariable> </elseActionList> </if> <!-- sample operation to do on a single item --> <showInfo> <text>F='${current_file}'</text> </showInfo> </actionList> </while> If your output is not line based, can you paste the script used to generate the list of files and/or sample output?


answered 09 Dec '12, 13:43

wojciechka's gravatar image

wojciechka ♦♦
accept rate: 26%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 09 Dec '12, 10:49

Seen: 1,634 times

Last updated: 09 Dec '12, 13:43