Error while using movefile

21 views (last 30 days)
Eva
Eva on 13 Sep 2017
Commented: Walter Roberson on 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

Answers (1)

Walter Roberson
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
Eva
Eva on 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 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

Sign in to comment.

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!