How to recover an unsaved "untitled2.m" script after computer crashed
392 views (last 30 days)
Show older comments
I have been working in an unsaved "untitled2.m" script when my computer crashed.
When restarting matlab this unsaved document was gone along with the .asv files in my current directory.
However, when opening a new script I noticed that the new scripts filename is "untitled3.m", which means that somewhere the "untitled2.m" document must exist. The question is where? I assume this is some temporary folder created somewhere while matlab is still running. But how do I access this folder/file using Macbook.
0 Comments
Answers (3)
Codey Nacke
on 2 Sep 2024
I had a similar issue and was able to recover the code. I had an untitled file that I was working on and hadn't yet saved when my power went out. I was able to find the script in the temp folder.
First, navigate to where Matlab is storing temp files by running tempdir then navigating to that folder in your file system.
Next, I found a folder called "Editor_wtfiy" that had a file called "LiveEditorEvaluationHelperE1112034879.m" that had a copy of my code. I assume that the "E1112034879" is a unique identifier for each script.
TLDR: Look in ~tempdir~/Editor_wtfiy/LiveEditorEvaluationHelper[...].m
Walter Roberson
on 2 Mar 2023
However, in practice that directory is used for MATLAB mostly to store files being built into a .slx or .xlsx, or code extracts when running LiveScript or running regular script section by section ("Run and Advance")
You could also look under ~/Library/'Application Support'/MathWorks/MATLAB but I don't think you will find anything useful there.
Time to invoke Time Machine.
2 Comments
Walter Roberson
on 3 Mar 2023
The file name might hypothetically be handled by something recorded in prefdir .
I just tested on my system, creating some untitled files and deleting them all. The next file had the next sequence number. (At least within the same session; I did not test closing MATLAB.)
Praprara
on 16 Sep 2024
Lol I came to this page 2 months ago for this same issue but since you hadn't commented, I wasn't been able to get back the file. But seeing this comment now, I finally know how to retrieve 'lost' matlab files. Thank you!
0 Comments
See Also
Categories
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!