I want to copy a file from a folder, one directory above the python script being interpreted, to a folder in the same directory the python script lives.
This is the folder structure.
-----/A
---------copyme.txt
-----/test
----------myCode.py
---------/B
I want to copy file copyme.txt
, from folder A
, to folder B
, under the test folder.
This is the code i tried:
import os
import shutil
shutil.copyfile('../A/copyme.txt', '/B')
However, i received this error:
Traceback (most recent call last):
File "test.py", line 4, in <module>
shutil.copyfile('../A/copyme.txt', 'B')
File "/home/user1/anaconda3/lib/python3.8/shutil.py", line 261, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
IsADirectoryError: [Errno 21] Is a directory: 'B'