Skip to main content

files and directories - DumpSave'ing while lengthy program runs


tldr: is there a way to load all files following a structure/append to DumpSave file


i would like to run a script following the structure:


Get['lib.wl']
data = initializeDataSet[]
DumpSave['save0', data]


result1 = compute1[]
DumpSave['save1', result1]
Clear[result1]

.
.
.

resultn = computen[]
DumpSave['saven', resultn]

Clear[resultn]

is there a good way to load all saves without going >>save0 to >>saven. Or is this manual work needed? A Get[name] where name allows for joker would suffice, but I don't think it exists. Putting them into a separate folder seems sensible.


Just saving at the end doesn't seem viable/safe to me in case of an unexpected early exit.


Edit: just discovered FileNames[] is a thing. the solution would be like:


names = FileNames[pattern,{directory}]
Do[Get[fileName], {fileName, names}]

Answer



You can use Get/@ FileNames["save*"].


Comments