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 [email protected]
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 to a host with WMI tester_V 6 782 Aug-10-2021, 06:25 PM
Last Post: tester_V
  Failing to get Stat for a Directory tester_V 11 957 Jul-20-2021, 10:59 PM
Last Post: Larz60+
  string.format() suddenly causing errors with google drive API zwitrader 0 471 Jun-28-2021, 11:38 PM
Last Post: zwitrader
  extra slashes in the network path for shutil.copy tester_V 3 888 Jun-02-2021, 07:57 AM
Last Post: supuflounder
  Copy column from one existing excel file to another file mkujawsk 0 887 Apr-14-2021, 06:33 PM
Last Post: mkujawsk
  failing to print not matched lines from second file tester_V 13 1,963 Apr-13-2021, 03:36 PM
Last Post: DeaD_EyE
  Windows 10 Installation failing (0x80070005) AdaptedLogic 4 3,483 Dec-31-2020, 07:39 AM
Last Post: caleb_cruze
  Failing to Zip files tester_V 4 779 Dec-01-2020, 07:28 AM
Last Post: tester_V
Smile Import error with local file colt 1 738 Nov-08-2020, 07:56 AM
Last Post: Gribouillis
  Copy mp3 file multiple times and rename Mar10 4 1,604 Sep-23-2020, 01:09 AM
Last Post: Mar10

Forum Jump:

User Panel Messages

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