Python Forum
Failing to copy file from a network to a local drive
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Failing to copy file from a network to a local drive
#1
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!
Oshadha likes this post
Reply
#2
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'
tester_V likes this post
Reply
#3
Yes! Smile
"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 Cry

What is it?
Thak you@
Reply
#4
Any ideas why I'm having this error?

Thank you.
Reply
#5
Just wanted to share,
Adding 'try' fixed the problem Cool

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! Big Grin
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Failing to connect by 'net use' tester_V 1 124 Apr-20-2024, 06:31 AM
Last Post: tester_V
  Why is the copy method name in python list copy and not `__copy__`? YouHoGeon 2 269 Apr-04-2024, 01:18 AM
Last Post: YouHoGeon
Question How to get a removable disc type in drive Daring_T 12 1,228 Feb-11-2024, 08:55 AM
Last Post: Gribouillis
  Copy Paste excel files based on the first letters of the file name Viento 2 437 Feb-07-2024, 12:24 PM
Last Post: Viento
  Input network device connection info from data file edroche3rd 6 1,022 Oct-12-2023, 02:18 AM
Last Post: edroche3rd
  open python files in other drive akbarza 1 685 Aug-24-2023, 01:23 PM
Last Post: deanhystad
  Integrating Google Drive in App Lahearle 0 469 Jul-19-2023, 05:51 PM
Last Post: Lahearle
  is it possible to copy image from email and place into excel file? cubangt 3 1,270 Nov-30-2022, 05:11 PM
Last Post: snippsat
  Please help me [copy and paste file from src to dst] midomarc 2 1,014 Nov-24-2022, 10:13 PM
Last Post: midomarc
  code to send attachments contained on the drive. stefanoste78 1 854 Oct-12-2022, 02:16 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020