-3

So I am using a function in python which is being called in Robotframework to copy a file from a source to destination I have used os.path.join() and os.listdir() and os.path.normpath() to get access to the folder and copy using shutil But everytime I get this error

WindowsError: [Error 3] The system cannot find the path specified: '\\10.28.108.***\\folder\\folder2\\out/*.*'

My code

from pathlib import Path
import shutil
import os

#filename = Path ("\\10.28.108.***\folder\folder2\out\001890320181228184056-HT.xml")

source = os.listdir("\\10.28.108.***\folder\folder2\out")
destination = "\\10.28.108.***\folder\folder2\"
for files in source :
    if files.endswith(".xml"):
        shutil.copy(files, destination)
A. Kootstra
  • 6,827
  • 3
  • 20
  • 43
Raja_Viki
  • 13
  • 2

2 Answers2

1

By this you can read your file.

filename = secure_filename(file_name.filename)
file_split = os.path.splitext(filename)
filename = file_split[0] + '__' + str(uuid.uuid4()) + file_split[1]
filepath = os.path.join(dest_dir, filename)
syspath = os.path.join(upload_dir, filepath)
file_name.save(syspath)
vipul gangwar
  • 313
  • 1
  • 4
  • 16
0

first thing here that check if you can access this folder(\10.28.108.\folder\folder2\out) from your file explorer

The other thing is you have to specify two slash if you are accessing remote folder below is example:

source = os.listdir(r"\\10.28.108.xxx\folder\folder2\out")
Amit Nanaware
  • 3,203
  • 1
  • 6
  • 19