Aug-10-2020, 02:47 PM
(This post was last modified: Aug-11-2020, 07:58 PM by MathCommander.)
Hi. I have a directory wich contains a set of files with the following format
The following names are examples of this format
I have to make a list of all the files whose end number belongs to an interval. To get this, I have used the following instruction
Can anybody help me?
Thanks.
"name" + "six digits number" + ".txt"
The following names are examples of this format
dog000001.txt
cat000054.txt
lion010101.txt
mouse123456.txt
cat000054.txt
lion010101.txt
mouse123456.txt
I have to make a list of all the files whose end number belongs to an interval. To get this, I have used the following instruction
files_list = glob.glob('*' + '[' + initial + '-' + final + ']' + '.txt')where initial and final are the left and right boundaries of the interval, respectively. For example, if I execute the before instruction with
initial = '000000'
final = '010000'the execution would return to me the following result
files_list = [dog000001.txt, cat000054.txt]but it doesn't occur. I have tried using ranges too but the range doesn't consider 6 digits if the number has less than 6 digits.
Can anybody help me?
Thanks.