Error while using movefile

21 Ansichten (letzte 30 Tage)
Eva
Eva am 13 Sep. 2017
Kommentiert: Walter Roberson am 13 Sep. 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

Antworten (1)

Walter Roberson
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
Eva
Eva am 13 Sep. 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 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

Melden Sie sich an, um zu kommentieren.

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!

Translated by