MATLAB Answers

copyfile: The system cannot find the path specified

145 views (last 30 days)
I get the follwoing error when using copyfile
The system cannot find the path specified.
I am using the following code
source='D:\Research\Thesis_work\Structural_uncertainty\data_collection\Precipitation\precip_hourly\p_39.3130_-87.3130.txt'
destination='D:\Research\Thesis_work\Structural_uncertainty\MatLab_codes\20180222\huc_0512011115\rainfall_data_hourly\p1.txt'
copyfile(source,destination)
is there anything wrong with the code or is it a some MATLAB bug?

  0 Comments

Sign in to comment.

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 3 May 2018
use exist(source,'file') to see if the file exists first. Your source file name contains multiple "." and "-'

  3 Comments

Abhinav
Abhinav on 3 May 2018
It shows that file does exist. The output was 2. I also tried to open the file using fopen and it was able to open the file.
Fangjun Jiang
Fangjun Jiang on 3 May 2018
then you need to check
[p,f]=fileparts(destination);
exist(p,'dir');
Abhinav
Abhinav on 3 May 2018
I see. It worked. I was using mkdir to create the destination folder in a wrong way, that's why destination folder didn't exist. I should have thought about it myself. Thanks a lot!

Sign in to comment.

More Answers (1)

HEEKWON LEE
HEEKWON LEE on 10 Aug 2018
Edited: Walter Roberson on 11 Aug 2018
I have same issue but little bit differnt.
Asource='\\11.11.11.11\a.png'
Bdes='D:\folder'
Copyfile Asource Bdes
But it has appeared message "can noy find file"
Also i was checked exist function.

  1 Comment

Walter Roberson
Walter Roberson on 11 Aug 2018
You have the wrong syntax for Asource. You are using remote file naming, which requires the general form
\\server\share\path\file
You have the server, 11.11.11.11, but then you skip the share and path and go directly to the file a.png
It is not really clear that copyfile supports remote file naming.
In any case you need
copyfile(Asource, Bdes)
Your current command is the same as
copyfile('Asource', 'Bdes')

Sign in to comment.

Sign in to answer this question.

Tags

Products