I am having some problems getting windows powershell to do what I want it to do. Essentially, I have 24 subfolders in my current folder, named Angle1, Angle2, etc. up to Angle 24.
In each of these subfolders there is a file called output.txt. In output.txt, there are 10 columns of data, separated by a blank space. I would like to get the 9th column of each output.txt file in each subfolder, and put them all in a new file in parent folder called total.txt. So, ultimately, I would have 24 columns of data, each separated by a space. The first column of total.txt would correspond to the 9th column of output.txt in Angle1, etc.
Note that the Angle folders have other subfolders which I want to ignore.
Despite many attempts, I have not been able to get this to work. I am not sure if I need to use the -Recurse option to do this, or if Powershell is even capable of doing this. IS there anyone here who is an expert at a powershell, that could say whether this is possible or not?
A small except from one output.txt file:
1348 2 26.0785 3.18115 20.5328 -0.79613 3.18115 2.51545 4.13292 0.278888
1348 2 26.8091 2.07125 19.4069 -0.0655152 2.07125 1.38956 2.49505 0.254024
1348 2 24.162 3.90054 20.4261 -2.71258 3.90054 2.40877 5.32677 0.0208912
1348 2 24.1527 3.90493 20.4233 -2.72189 3.90493 2.40595 5.33346 0.00646916
1348 2 24.1436 3.88005 20.4429 -2.73095 3.88005 2.42555 5.32881 0.0127918
1348 2 24.1087 3.87723 20.4519 -2.76586 3.87723 2.43455 5.34882 0.0198102
1348 2 24.2572 3.83432 20.4136 -2.61737 3.83432 2.39624 5.22442 0.0243901
1348 2 24.1609 3.7174 19.8739 -2.71375 3.7174 1.85659 4.9629 0.0838124
The code that I was using was in Linux, which worked to some degree:
awk '{print $9}' Angle1/output.txt >>tmp
for ((i=2;i<25;i++))
do
awk '{print $9}' Angle${i}/output.txt |paste -d " " tmp - >>total.txt
mv total.txt tmp
done
mv tmp total.txt
However, now I need to run in Powershell, not linux. At this time I don't really have any code that remotely works for this. Basically a conglomeration of Get-Child commands etc. but nothing that came close to what I wanted.