(Jul-24-2020, 07:59 PM)pythonnewbie138 Wrote: I think I'm lacking understanding of what I'm doing withfile
early in the script.
I'm actually unsure of howfile
is created in the first place. There's no strict definition at the beginning. Googling hasn't yielded anything useful yet.
for file in location:
file
is assigned the value of each item in location.if location was a list
[0, 1, 2, 3]
as it looped through each timefile = 0 # first loop file = 1 # second loop file = 2 # third loop file = 3 # forth loopfile would now by pointing to 3 after the loop
(Jul-24-2020, 07:59 PM)pythonnewbie138 Wrote: I tried to manually assignf2
as the value forfile
withfile = str(f2)
before the subprocess command but that yields the following error:
I didn't think it would work but I'm at a loss at the moment.
Error:AttributeError: 'str' object has no attribute 'name'
In the loop you have
list1.append(file.name)so list1 now contain strings of the file names
when the selection is made
f2 = list1[int(f1)]f2 now contains the chosen filename string
f2.split(".")[0]would give the filename string less its extension.