CatOrSplitFile
No License
CATORSPLITFILES concatenates or splits files with an optional token header.
CATORSPLITFILES('CAT',FILENAME,TARGETFILENAME,param,value, ...)
FILENAMES = CATORSPLITFILES('SPLIT',TARGETFILENAME,param,value, ...)
CAT (concatenate) PARAMETERS, VALUES AND DEFAULTS
Parameter Values Defaults
--------- ---------------- --------
HEADER 'OFF','%','NO%' '%'
SILENT 'OFF','ON' 'OFF'
PROP 'OFF','ON' 'OFF'
If HEADER is % (default) each file that is combined will be titled with a
comment that begins with % and is easily recognisible. If you should
desire to split the file up again, CATORSPLITFILES can use this comment
to do it properly.
If HEADER is NO%, the action is very similar to the default action except
the comment does not begin with %.
If HEADER is OFF, then all the files are combined into one large one. If
this is done it may not be reversible since the only way to split them
again is with the FUN feature.
If SILENT is ON, the CATORSPLITFILE will not prompt the user before
overwriting a file.
The PROP feature is proprietary and not available to the public.
which may not split the file where it was originally since it will split
on the function definitions. If one of the original files had more than
one function definition or if one of the original files
SPLIT PARAMETERS, VALUES AND DEFAULTS
Parameter Values Defaults
--------- ---------------- --------
HEADER '%','NO%','FUN' '%'
SILENT 'OFF','ON' 'OFF'
BACKUP 'OFF','ON' 'ON'
SPLITTO string where it came from
If HEADER is % (default) the file will be split on a comment produced
with CATORSPLITFILES that begins with % and is easily recognisible.
If HEADER is NO%, the action is very similar to the default action except
the comment does not begin with %.
If HEADER is FUN, then CATORSPLITFILE will split on function definitions
putting each function in a different m-file.
If SILENT is ON, the CATORSPLITFILE will not prompt the user before
overwriting a file.
If BACKUP is ON (default), CATORSPLITFILE will not backup files before
overwriting them. The backed up file will have the same name, but will
have the .bak extension.
If SPLITTO is not specified, then the file will split to the location
from where it was combined. For example, if you combined c:\ml\file1 and
c:\ml\file2 to bigfile, bigfile will be split back into c:\ml\file1 and
c:\ml\file2. But if you specify SPLITTO to be c:\temp, then bigfile will
be split into c:\temp\file1 and c:\temp\file2.
CATORSPLITFILE will return the names of the files that are produced when
splitting
Example
% Combine all the files in the working directory into one
CatOrSplitFiles('cat','ConcatenateFilesTest','tst.m','header','no%');
% Display the combined file
type cattest
% Split it back up to reverse the process
filenames = CatOrSplitFiles('split','cattest.m', ...
'backup','on','header','no%','splitto',pwd);
% Look at the directory to see that the backup files have been made
dir
Uses
ParseVarargin
Used by
SearchReplaceManyGUI
keywords
varargin cat concatenate append add split divide break up combine file header
See also: ParseVarargin SearchReplaceManyGUI
It's not fancy, but it works
Cite As
Michael Robbins (2024). CatOrSplitFile (https://www.mathworks.com/matlabcentral/fileexchange/8119-catorsplitfile), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 | Multiple changes + 2 new utilities: WhichCatOrSplitFiles and RemoveCatOrSplitFilesHeader |