Nov-23-2022, 10:03 PM
Greetings!
I'm trying to copy files if the file name has a digit and it is in the range of 0-3.
files in a directory go like this:
file.txt
file-1.txt
file-2.txt
file-3.txt
...
file-50.txt
the snippet I have does not print anything for some reason.
I'm trying to copy files if the file name has a digit and it is in the range of 0-3.
files in a directory go like this:
file.txt
file-1.txt
file-2.txt
file-3.txt
...
file-50.txt
the snippet I have does not print anything for some reason.
from pathlib import Path import re dr ='C:\01' for ef in Path(dr).iterdir() : fn = Path(ef).stem #print(f" Names -> {fn}") num = re.findall(r'\d+', fn) #print(f" Digit -> {num} - {fn}") if num in range(0,3) : print(f" File to copy -> {ef}")Thank you!