Error while using movefile
21 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Walter Roberson
on 13 Sep 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 Comments
Walter Roberson
on 13 Sep 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
See Also
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!