So I'm writing a python script that loops through a list with two file names that are in the same directory. Then the script uses os.path.join() to get the absolute path of this file.
The code I use is this:
for i in ["my filename with spaces 1.txt", "my filename with spaces 2.txt"]:
path = os.path.join(cwd, "testing", i)
subprocess.run("aws s3 cp " + path + " s3://" + selectedEnv + "-pathname/to/folder, shell=True)
The issue is that the script runs, but something about the spaces in my filenames causes the aws cli to return Unknown options: "with", "spaces"... and so on. I've tried escaping the spaces with the back tick `, backslashes \ and carets ^, none of which fix the issue.
My terminal is currently Windows Powershell, but I'm trying to ensure that this python script can run on both linux and powershelll command lines.