Error while using movefile

21 visualizaciones (últimos 30 días)
Eva
Eva el 13 de Sept. de 2017
Comentada: Walter Roberson el 13 de Sept. de 2017
Hey all,
I am creating a test report and would like to rename it and move it a specified folder afterwards. I am using movefile but it keeps popping an error saying
Error using movefile.
No matching files were found.
[FileName, PathName, FilterIndex] = uiputfile({'*.pdf';}, ...
'Save the report as');
FileFormat = 'pdf';
FileNameExtension = 'pdf';
ReportStructureFileName = 'ReportStruct'; %'ReportStruct_PDF';
% Name der ".m"-Datei in welcher der Code für den Report generiert wird
publish( strcat(ReportStructureFileName, '.m'), ... % Aufruf der Datei und erstellen des Reports
'format', FileFormat, ...
'showCode', false, 'createThumbnail', false);
DefaultFileName = strcat(ReportStructureFileName,'.', FileNameExtension);
movefile(DefaultFileName, FileName); %%Extension
movefile(FileName, PathName);
end
I am thankful for any idea.
Br, Eva

Respuestas (1)

Walter Roberson
Walter Roberson el 13 de Sept. de 2017
The output file is not directly in the current directory: it is always in the html sub-directory of the current directory.
DefaultFileName = fullfile( 'html', [ ReportStructureFileName,'.', FileNameExtension] );
  2 comentarios
Eva
Eva el 13 de Sept. de 2017
Hey Walter, thanks a lot for your quick answer. I tried to use your snipped of code instead but it gives the same error as before...
Walter Roberson
Walter Roberson el 13 de Sept. de 2017
You have two movefile(); why not combine them into one?
if exist(DefaultFileName, 'file')
movefile(DefaultFileName, fullfile(PathName, FileName) );
else
fprintf('Failed to find the output file, was looking for "%s"\nContents of the "html" directory are:\n', DefaultFileName);
ls('html')
end

Iniciar sesión para comentar.

Categorías

Más información sobre File Operations 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!

Translated by