[Tutor] Executing shell commands

Phil phillor9 at gmail.com
Sun Feb 16 02:54:50 EST 2020


On 16/2/20 3:04 pm, Mats Wichmann wrote:
> you dont need to run an external command to collect the files, look at 
> the glob module and even more apropos the pathlib module. 

It turned out to be easier that I had expected and this is what I came 
up with:

from pathlib2 import Path
from glob import glob

path = Path("/home/phil/Downloads/")

for x in path.glob("*.gpx"):
     print (x)

I think that all I need to do now is to insert each file name into a 
subprocess.run() string which will then send each .gpx file to my 
navigator. A task for a later time.

-- 
Regards,
Phil



More information about the Tutor mailing list