I'm having trouble getting shutil.move() working properly, I can use os.getcwd() to utilize the working directory, however I'm missing the '' that comes after the directory and before the file name, I've tried inputting a ` '\' after the directory but it doesnt recognise this.
Error is below, missing the '' after GUI and before test.pdf. FileNotFoundError: [Errno 2] No such file or directory: 'Z:\PyCharm\GUItest.pdf'
output_folder = input()
source_dir = os.getcwd()
if os.path.isfile(f'{output_folder}test.pdf'):
print('File already exists, saved to your Z drive!')
shutil.move(f'{source_dir} test.pdf', 'Z:\') # needs to look in directory the program is ran from.
else:
shutil.move(f'{source_dir} test.pdf', output_folder) # same as above.
CodePudding user response:
Local files start with .\
in Windows.
Try shutil.move(r'.\test.pdf', r'Z:\test.pdf')