Jan-25-2020, 02:42 PM
Hello,
I need to build a command and pass it to an external application.
Filenames may have spaces in them, so I must double quote them, but I can't figure out how:
Thank you.
I need to build a command and pass it to an external application.
Filenames may have spaces in them, so I must double quote them, but I can't figure out how:
fullstring="-t " files = sys.argv[1] output = sys.argv[2] for filename in glob(files): #BAD fullstring = fullstring + f" -i gpx -f '{filename}'" #BAD fullstring = fullstring + f" -i gpx -f \"{filename}\"" #BAD fullstring = fullstring + f" -i gpx -f ""{filename}""" fullstring = f"gpsbabel {fullstring} -x track,discard -o gpx -F {output}" print(fullstring) subprocess.run(fullstring)FWIW, I'm using Windows, but users might run this script on other OS's.
Thank you.