I have the following files names in a directory:
{"myfileaxis.data", "nb100", "nb1000", "nb1100", "nb1200", "nb1300", \
"nb1400", "nb1500", "nb1600", "nb1700", "nb1800", "nb200", "nb2000", \
"nb2100", "nb2200", "nb2300", "nb2400", "nb2500", "nb2600", "nb2700", \
"nb2800", "nb2900", "nb300", "nb3000", "nb3100", "nb3200", "nb3300", \
"nb3400", "nb3500", "nb3600", "nb3700", "nb3800", "nb3900", "nb400", \
"nb4000", "nb500", "nb600", "nb700", "nb800", "nb900", \
"parmcnt.lammps"}
In each file I have the followings:
{"dump.lammpstrj", "force.txt", "len.txt", "strain.txt", "stress.txt"}
I need to import the related len.txt and force.txt from each nb100, nb200,... folders, such that It can read len.txt and force.text from nb100 for instance, (and run the piece of program I have written to do calculations based on the text files data) and finally save the result as for example result100.
I have done this manually [in a stupid way] for each folder (read one folder nb100//do the calculation/save as reault100 , then I changed the name manually to read the next one and change the result200 name and so on...
for example I set the directory as:
SetDirectory["/Users/Desktop/April10/coeff4000/nb100"]
FileNames[]
and :
rawforce = Import["force.txt", "Data"];
rawlen = Import["len.txt", "Data"];
rawcntpos = Import["inipos.txt", "Data"];
But each time I have to change nb100 to nb200 , ... to read and store the related force.txt, len.txt and inipos.txt . I was wondering if there is an easier way to program the above.
Here is an example of the piece of code I have:
SetDirectory["/Users/Desktop/April10/coeff4000/nb100"]
FileNames[]
rawforce = Import["force.txt", "Data"];
rawlen = Import["len.txt", "Data"];
rawcntpos = Import["inipos.txt", "Data"];
(*****Calculation body****)
t1 = Table[{rawcntpos[[i]][[3]], rawcntpos[[i]][[4]],
rawcntpos[[i]][[5]]}, {i, 1, Length[rawcntpos]}];
neighList = ParallelTable[siteLoc = t1[[i]];
checkDist = Table[rvec = t1[[k]] - siteLoc;
dist2 = rvec . rvec;
And[dist2 > 0.1, dist2 < sp + m] , {k, 1, Length[t1]}];
Sort[Flatten[Position[checkDist, True]]], {i, 1, Length[t1]}];
crossbond = ParallelTable[siteLoc = t1[[i]];
checklist = Table[rvec = t1[[k]] - siteLoc;
dist = Sqrt[rvec . rvec];
And[dist == 2*radf, i != k], {k, 1, Length[t1]}];
Sort[Flatten[Position[checklist, True]]], {i, 1, Length[t1]}];
bondlist100 = Union[Join[crossbond, neighList]];
My question is how to write a program that automatically loop over all nb100, nb200 ,nb300 ...
and read force.txt len.txt and inipos.text and store the bondlist related to nb100, nb200, nb300...as bondlist100,bondlist200,bondlist300 ...
Thank you so much