copyfile: The system cannot find the path specified

28 visualizaciones (últimos 30 días)
Abhinav
Abhinav el 3 de Mayo de 2018
Movida: Fangjun Jiang el 18 de Jun. de 2024
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?
  1 comentario
Vasiliki Vasilopoulou
Vasiliki Vasilopoulou el 17 de Jun. de 2024
Movida: Fangjun Jiang el 18 de Jun. de 2024
Hello,
I have a problem. I want to run an already code but the message that appears is "the system cannot the path specified".
Has it a relationship with clusters? I don't understand.

Iniciar sesión para comentar.

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 3 de Mayo de 2018
use exist(source,'file') to see if the file exists first. Your source file name contains multiple "." and "-'
  3 comentarios
Fangjun Jiang
Fangjun Jiang el 3 de Mayo de 2018
then you need to check
[p,f]=fileparts(destination);
exist(p,'dir');
Abhinav
Abhinav el 3 de Mayo de 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!

Iniciar sesión para comentar.

Más respuestas (2)

HEEKWON LEE
HEEKWON LEE el 10 de Ag. de 2018
Editada: Walter Roberson el 11 de Ag. de 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 comentario
Walter Roberson
Walter Roberson el 11 de Ag. de 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')

Iniciar sesión para comentar.


Hussein A A
Hussein A A el 5 de Jun. de 2023
Matlab code is case sensitive, so make sure about the exact spelling within your OS. Moreover, you can try loading or reading and writing of such path into the source and destination file Use fprintf is another alternative
  1 comentario
Walter Roberson
Walter Roberson el 5 de Jun. de 2023
MATLAB code is case-sensitive, but the question has to do with difficulty with files . Whether any particular file name is case sensitive or not depends upon the way the particular file system is configured.
By default, NTFS (Windows) and HFS+ (MacOS) and APFS (MacOS) are not case-sensitive file systems, but all three of those can be configured as case-sensitive.
(Apparently these days on Windows 10 you can enable case sensitivity for individual folders; https://www.windowscentral.com/how-enable-ntfs-treat-folders-case-sensitive-windows-10 )

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by