47 lines
1.5 KiB
Matlab
47 lines
1.5 KiB
Matlab
function createBeamtimeFolder(projectName)
|
|
%createProjectFolder Create a project folder with a fixed subfolder structure.
|
|
%
|
|
% createProjectFolder(projectName)
|
|
%
|
|
% Creates a new folder in the current directory, named by the input
|
|
% string projectName, and inside it the subfolders:
|
|
% Analysis, Images, LabBook, NEXAFS, Photos, pressure,
|
|
% PShell, RGA, SES.
|
|
%
|
|
% The function is cross-platform and uses fullfile to construct paths,
|
|
% so it works on both macOS and Windows. If folders already exist,
|
|
% mkdir leaves them unchanged.
|
|
%
|
|
% Example:
|
|
% createProjectFolder('Sample_2026_02_26');
|
|
|
|
if nargin < 1 || (~ischar(projectName) && ~isstring(projectName))
|
|
error('createProjectFolder:InvalidInput', ...
|
|
'projectName must be a character vector or string scalar.');
|
|
end
|
|
|
|
% Ensure string scalar for consistent handling
|
|
projectName = char(projectName);
|
|
|
|
% Base path: current folder
|
|
basePath = pwd;
|
|
projectRoot = fullfile(basePath, projectName);
|
|
|
|
% List of subfolders to create
|
|
subFolders = {'Analysis', 'Images', 'LabBook', 'NEXAFS', ...
|
|
'Photos', 'Pressure', 'PShell', 'RGA', 'SES'};
|
|
|
|
% Create main project folder
|
|
if ~exist(projectRoot, 'dir')
|
|
mkdir(projectRoot);
|
|
end
|
|
|
|
% Create all subfolders
|
|
for k = 1:numel(subFolders)
|
|
thisPath = fullfile(projectRoot, subFolders{k});
|
|
if ~exist(thisPath, 'dir')
|
|
mkdir(thisPath);
|
|
end
|
|
end
|
|
end
|