I am attempting to move files inside of a subdirectory into a temp folder. Here is my code:
with tempfile.TemporaryDirectory() as tempDirectory:
for root, dirs, files in os.walk(fileDestination, topdown=True):
for file in files:
shutil.move(file, tempDirectory)
When I look at my debugger I can see the values of the file variable holding the files I want to move. But nothing moves and I am then given the error FileNotFoundError that references the file I want to move. When I look into my file explorer I can see that the file did not move.
Figured it out on my own. So even though file variable was holding the filename it was not holding the entire path to the file. The below code works: