From eebd04530b6fcb193f6d547a773ed10b8639df38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20L=C3=B6vfors?= <william.lovfors@gmail.com> Date: Tue, 5 Oct 2021 14:37:20 +0200 Subject: [PATCH] added a function that can rename profile likelihood file names to be slightly worse. Useful if e.g. rerunning parameters when the old best files might be infeasible. Note that the parameter values are not touched. --- RenamePLFiles.m | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 RenamePLFiles.m diff --git a/RenamePLFiles.m b/RenamePLFiles.m new file mode 100644 index 0000000..ea0c68f --- /dev/null +++ b/RenamePLFiles.m @@ -0,0 +1,18 @@ +function [] = RenamePLFiles(path, offset) + if nargin<1, path='.'; end + if nargin<2, offset = 1; end + + files = dir(path); + for i = 1:length(files) + [match] = regexp(files(i).name, '\[(min|max),.+\(([-0-9.]+)\)','tokens'); + if ~isempty(match) + value = str2double(match{1}{2}); + if strcmp(match{1}{1},'max') + newValue=value-offset; + elseif strcmp(match{1}{1},'min') + newValue=value+offset; + end + movefile([files(i).folder '/' files(i).name], strrep([files(i).folder '/' files(i).name], match{1}{2}, sprintf('%.4f',newValue))) + end + end +end \ No newline at end of file -- GitLab