Error while using movefile
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Walter Roberson
am 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 Kommentare
Walter Roberson
am 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
Siehe auch
Kategorien
Mehr zu File Operations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!