I'm trying to move a file from one folder to another using Python. I've tried using shutil, os.replace, os.rename but I'm getting the same error each time of TypeError: move() missing 1 required positional argument: 'dst' enter image description here
Here is a snippet of my code (made ambiguous to avoid displaying sensitive info):
import os
import shutil
filename = f"fileNamePlaceholder"
directory = f"originalFileLocation"
destination = f"newFileLocation"
shutil.move(f'"{directory}{filename}","{destination}"')
Pretty basic, but I get the TypeError: move() missing 1 required positional argument: 'dst' error each time. I've tried pasting the output into the command line, and it does work and moves the file, but when I try to run it directly, I get the error. I've also tried the os library to move the file, but the 'dst' error as well. This should be pretty basic but I just can't get it to work.
Note: I'm working on Windows 10, in a Linux Bash Shell.
take care to your quotes, you have a single argument in your shutil.move()
:
you wrote: shutil.move(f'"{directory}{filename}","{destination}"')
should be shutil.move(f"{directory}{filename}",f"{destination}")