|Hello, i have thousand txt files called "Posizioni_Number1_Number2.txt", eg. Posizioni_2160_004.txt.|
The numbers are always multipliers of 4, so surely there is no file called Posizioni_2161_005.txt. And the second number goes from 000 to 356.
In each of them data are formatted like this:
nodenumber x-coordinate y-coordinate x-velocity y-velocity 1 3.310E-001 3.945E-001 4.694E+000 7.7593E-001
all in a unique line and separated by several spaces.
I need a batch file, or something else, that in input accepts the endpoints for the first number (eg 2160 2220) and, for each file (maybe with a double for loop incrementing by 4), takes only last 4 numbers inside (ignoring all text and the first number) and append them in a new txt file named like the first number in the txts names.
So if i have files like "Posizioni_2160_004.txt", "Posizioni_2160_008.txt", "Posizioni_2160_12.txt" should be created one file named 2160.txt with corresponding data placed sequentially. But for other files like "Posizioni_2172_004.txt", "Posizioni_2172_008.txt" "Posizioni_2172_12.txt" a new file must be created, named 2172.txt. and this repeated for each file between the endpoints given in input.
But it's not over!:)
I need that if a file with a specific second number in the name does not exist (eg Posizioni_2160_008.txt), instead of the 4 numbers, in the corresponding file (2160.txt), in the right place ( after the 2160_004 data) , must be inserted four NaN.
Can anyone help me? I know it's a mess-.-'..but this script could save me days of boring and repetitive job! I hope i was clear enough and sorry for my bad english.