Link to home
Start Free TrialLog in
Avatar of enthuguy
enthuguyFlag for Australia

asked on

How to extract string value and construct contact string in Windows Batch

Hi
Could you help with below please.

Scenario:

- In Windows batch, would like to check a folder with specific file pattern e.g *.sif. We might find 1 or more files. Files are in sif extension but it just a text file in xml style. (not binary)

- Look for string "PROCESS_NAME" and get the value of of it. E.g PROCESS_NAME="TEST Workflow 1"

- Loop through all files in the directory and get all values. E.g. if we find "TEST Workflow 1" and "TEST Workflow 2" etc etc.

- Variable should be set like below.
e.g workflow_list='TEST Workflow 1','TEST Workflow 2','TEST Workflow 3'

If it is easy in powershell, we can do that, but is it easy to bring the value back to batch variable please

Have attached two sample files.

Thanks in advance :)
wf_nxg_application_error_handler_wor.txt
wf_nxg_publish_error_republish_batch.txt
Avatar of Bill Prew
Bill Prew

Should be doable in a BAT script, working something up...


»bp
Avatar of enthuguy

ASKER

Thanks a lot Bill :)
Hi Bill
sorry, based on the new finding the way powershell accepts
can we surround with escape char ` please

workflow_list=`'TEST Workflow 1`'`,`'TEST Workflow 2`'`,`'TEST Workflow 3`'
What do you want the actual DOS environment variable to contain?  Do you really want all those varied quotes?

`'TEST Workflow 1`'`,`'TEST Workflow 2`'`,`'TEST Workflow 3`'

Open in new window


»bp
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a lot bill, really appreciate ur help
Thanks once again Bill, that was a timely help and it worked perfectly for me