How to change values in space separated files
I have a text file whose data will be as below.
win10x64 ~\erwin Notallowed1! "erwin Data Modeler r9.7 (32-bit)_2500.exe" SilentInstall.exe win10x64clone1 ~\erwin Notallowed1! "erwin Data Modeler r9.7 (64-bit)_2500.exe" DM64.exe win10x64clone2 ~\erwin Notallowed1! "erwin Mart Server r9.7 (32-bit).exe" SilentInstall.exe win10x64clone3 ~\erwin Notallowed1! "erwin License Server r9.7 (32-bit).exe" SilentInstall.exe
Each line will have multiple values separated by space.
If a value contains space in it, the value is surrounded by quotes.
My task is to check how many values are there in each line.
If the line contains 5 values, I need to replace the 4th value with the string contained in a variable.
If it contains 4 values then also I need to replace the 4th value followed by appending 5 th value to it as SilentInstall.exe
If the value I am replacing contains spaces then I need to surround the new value with quotes.
Any one can suggest how to do this,??
0 Comments
[ + ] Show comments
Answers (2)
Please log in to answer
Posted by:
ur00361883
7 years ago
Got solution with AutoIT.
But we need to implement this in Powershell.
At present I am calling the autoit exe from powershell script as a temporary solution.
Please find the script link below.