Hi,
I'm trying to copy files from a network folder.
For some reason my code produces an error:
import os
import shutil
fname = 'somelog_file.txt'
p04 = 'D:\\JFLogs\\p04\\' ## local folder ##
h04 = '\\\\FF04OBS0004\\c$\\dir\\subdir\\'
fto_download = h04+fname
print (fto_download)
shutil.copy(fto_download, p04)
Any help appreciated!
Thank you!
This
Error:
\\FF04OBS0004\c$\dir\subdir\somelog_file.txt
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Temp\atom_script_tempfiles\05d938a0-5a1f-11eb-857f-2dd3f1980bd4", line 19, in <module>
shutil.copy(fto_download, p04)
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 415, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 261, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '\\\\FF04OBS0004\\c$\\dir\\subdir\\somelog_file.txt'
Yes!
"No such file or directory...."
I can map the directory to my Server and I see the files and access etc...
I do not understand what I'm doing wrong
What is it?
Thak you@
Any ideas why I'm having this error?
Thank you.
Just wanted to share,
Adding 'try' fixed the problem
import os
import shutil
fname = 'somelog_file.txt'
p04 = 'D:\\JFLogs\\p04\\' ## local folder ##
h04 = '\\\\FF04OBS0004\\c$\\dir\\subdir\\'
fto_download = h04+fname
print (fto_download)
try:
shutil.copy(fto_download, p04)
except Exception as e:
print (e)
Thank you!
