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:
FWIW, I'm using Windows, but users might run this script on other OS's.
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:
1 2 3 4 5 6 7 8 9 10 11 |
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) |
Thank you.