deleteUnusedMFiles(​)

This function aims to help the user delete unused .m files in a certain directory automatically
59 Downloads
Updated 22 Oct 2016

View License

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% (!!!!) WARNING, ACHTUNG, CUIDADO, ATTENTION: This function was created to
% help the user DELETE unused files in an automated way. Use it CAREFULLY
% and under your own responsability. I DO NOT TAKE ANY RESPONSABILITY for
% any damage caused to your computer/files!!!!
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This function searches for unused m files and let's the user delete
% them, or make a copy to a backup directory before deleting them.
% The procedure is simple: the native matlab's function
% matlab.codetools.requiredFilesAndProducts( 'filename_function.m' ),
% analyzes the function 'filename_function.m' in the current directory
% (pwd) and finds all dependant functions. In other words, this function
% returns all functions that are required for 'filename_function.m' to work
% properly. When a function does not require any other function to run
% apart from itself, matlab will just return the name of the function itself.
% Therefore, we can analyze all m files in a certain directory and find
% which functions are required for each file. We concatenate all these
% 'USED & REQUIRED' files in a variable. After checking all files, we
% compare the used & required files with the list of filenames on that
% directory. The filenames that don't appear in the used & required list
% are the functions that aren't called by anyone apart from themselves.
% This can have two meanings: 1) This function is a MAIN function that
% calls other subfunctions but is not called by anyone (like if you create
% a main GUI file/script) or 2) This function is not used and can be safely
% removed from this directory.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Cite As

Mbvalentin (2024). deleteUnusedMFiles() (https://www.mathworks.com/matlabcentral/fileexchange/59883-deleteunusedmfiles), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Startup and Shutdown in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0