is it possible to copy a file on itself?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Idin Pushkin
el 5 de Abr. de 2019
Comentada: Idin Pushkin
el 6 de Abr. de 2019
hello
i have some files in current folder which were copieed here from other folder. i have changed content of some of them in the original folder and now i want to copy them again to the current folder. but it says u cant copy a file or directory onto itself.
is there anyway for doing this?
thanks
0 comentarios
Respuesta aceptada
Walter Roberson
el 6 de Abr. de 2019
[file,path,indx] = uigetfile( ...
{'*.DATA;*.PVO;*.PVP;*.PVI;*.slx;*.INC','Eclipse Files (*.DATA,*.INC)';
'*.PVO;*.PVP;*.PVI;*.INC','PVTi files (*.PVO,*.PVP,*.PVI)';...
'*.*', 'All Files (*.*)'},'Select a File','MultiSelect', 'on');
if isequal(file,0)
disp('User selected Cancel');
else
if ischar(file); file = {file}; end
file(ismember(file, {'.', '..'})) = [];
file = fullfile(path, file);
for i = 1:length(file)
copyfile(file{i});
end
end
Más respuestas (2)
dpb
el 5 de Abr. de 2019
That isn't copying a file onto itself; there's nothing to prevent you doing what you want.
Your copyfile command isn't referencing the alternate folder in the source file it would appear by the error; however, you neglected to show us the command as you wrote it so we can't do more than surmise the cause.
If your current working directory is the target, then
otherdir='c:\that\otherdirectory';
copyfile(fullfile(otherdir,filename),filename)
should have no issues. If you are in the other directory when trying, then
targetdir='c:\that\targetlocation';
copyfile(fullfile(targetdir,filename),filename)
To be sure, wherever you are, use fully-qualified file names for both source and target.
0 comentarios
Idin Pushkin
el 6 de Abr. de 2019
2 comentarios
Walter Roberson
el 6 de Abr. de 2019
You copyfile() with only one argument. Which directory do you want the files to end up in?
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!