I’m writing a python script that is supposed to manage my running files. I want to make sure that the source and target folder exist before I run it and I can do this with os.path.exists. However, I have a set of foldernames runner<i>. Is there a way to check that there is some folders begining with that name?
For example, if in the path
/path/to/runners
I have at least one folder named runner:
/path/to/runners/ $ ls
file1.txt
file2.txt
folder1
folder2
runner1
runner35
zfolder
Then the result is true. Remove runner1 and runner35 and it will be false.
You could do the following:
That uses the helpful
anyfunction and a generator expression.