im trying to write a program that allows you to handle files and folders (move, copy, read etc...). Im following Bro Code python playlist. The issue that I am encountering is that I can only move files to files with the os.replace method and I would like to move it to folders for example but get [WinError 5] Access Denied. Same error message when I try to delete the file/folder in pycharm.
Here is an extract of my faulty code :
if os.path.isdir(path):
print('That location is a folder!')
exploit = input('Do you want to move or delete the folder')
if exploit == 'move':
dst = (input('Where do you want to move the folder to ( destination path needed):').replace('\\', '\\\\'))
os.replace(path, dst)
print(f'{path} was moved to {dst}')
Thanks for answering
I already tried using the shutil.move method but it did not work either. I get [WinError 5] Access Denied. I also tried running it as an admistrator and have made sure the file is well closed everywhere before running the code.