Ok, I have a directory with many files and subdirectories; among these ones there are 20 directories called mbr001
, mbr002
, ... until mbr020
that are the ones I am interested in.
I want to write a program that iteratively goes into mbr001
, do somethings, then to mbr002
, do the same things, and so on.
A solution with Python's os.chdir('./mbr001')
until 20 seems pretty inefficient.
Besides, when I am in such directories, let's say for example mbr012
, I want to create a variable that has in its name the number of the mbr where I am, in this case 12. Something like variable = 'mbr012_file.dat'
. (This variable
is used in what I am doing inside each directory, not relevant here).
What I would need would be something like this (note this is pseudo-code):
for i in mbr[i]:
variable = "mbr[i]_file.dat"
...
How can I do the loop and the variable naming? Thanks in advance.