Recovery & Sessions

What to do when a file is deleted while open on Mac

Note My still has your text on screen even though the file it came from is gone. Here is how to keep it, and how to put it back somewhere real.

You switch back to the editor and something has happened underneath it. A branch checkout removed the file. A build script cleaned the folder. Someone dragged it to the Trash, or a sync client decided it belonged somewhere else. The tab is still open, the text is still on screen, and the file it came from no longer exists.

This is a recoverable situation, and in Note My it is a designed one. The important thing is not to close the tab. Everything below explains what you are being told, what each button does, and how to get the text back onto disk.

Important

The copy that matters is almost always the one in front of you, and that is the copy Note My protects. Keep the tab open and your text stays whole, safe against a crash, and ready to be written out wherever you choose.

The message, and the two buttons it gives you

Note My tells you as soon as the file behind an open tab is gone, so you find out while the text is still in front of you rather than hours later when you go looking for it. You get the same warning in the awkward cases — a file on a network volume, a disk that drops out and comes back — and being told early is what makes the rest of this straightforward.

When the file goes, you get a sheet:

"«Report.md» was deleted from disk."

Two buttons: Keep in Editor and Close Tab. The choice is a plain one and it is yours to make: the text on screen becomes the surviving copy, or you let the document go. Almost every time, you want the first.

If the affected tab is not the one you are looking at, the sheet does not leap in front of you. The question waits on that tab and appears when you switch to it, so you are never pulled out of one document by something that happened in another. If the file has come back by the time you get there, you are not asked at all.

Keep in Editor: your text becomes the only copy

Choose Keep in Editor and the tab stays open, with no file behind it any more. Three things happen straight away.

The tab is marked unsaved. A leading * appears on the tab title and in the title bar, and it stays there until you write the text out somewhere. Treat that star as a job outstanding: it is the difference between text on your screen and text on your disk.

Our auto-recovery safety net then takes over. It holds a private copy of your unsaved work, so a crash, a forced quit or a power cut does not cost you the text you have just rescued. There is nothing to switch on and no setting to get wrong. It all happens on your Mac: nothing is uploaded, there is no account, and your text never leaves the machine.

And the badge in the status bar changes to say the file is missing. That is the reading you get for as long as the file is gone: a missing file is never left sitting behind some smaller notice, so a glance at the status bar always tells you the serious thing first.

At this point your work is safe against a crash or a power cut. The next step gives it an address on disk again — somewhere you can back up, reopen tomorrow and hand to someone else.

Writing it back to disk

  1. Choose Keep in Editor

    Do this before anything else, and before switching tabs. Closing the tab is what puts the text at risk; keeping it open costs nothing.

  2. Save As, not Save

    Press ⇧⌘S for File ▸ Save As…. A plain ⌘S takes you to the same panel on a tab in this state, so whichever shortcut is already in your fingers will get you there.

    The panel arrives with a sensible extension already filled in, matched to the document by our advanced language identifier. That saves retyping it, and the file opens later with the same colouring it has now.

  3. Save it somewhere that is not the folder that just lost it

    If a script or a checkout removed the file, the same thing may remove it again. Write to your Desktop or a scratch folder first, confirm the contents, then move it back once you know why it disappeared.

  4. Check the star has gone

    Saving clears the leading * from the tab title. If the star is still there, the save did not complete — check that you picked a folder you can actually write to, and try again. When it has gone, open the new file once and confirm it holds what you expect.

If you want a second copy without changing what the tab points at, File ▸ Save a Copy As… (⌥⇧⌘S) writes one out and leaves the tab where it is.

What happens if the file reappears

A checkout that removed the file may put it back a minute later. Note My notices, and it always asks you first. A file that reappears is never loaded over your text quietly, whatever you have set the change mode to. The file that came back is not necessarily the file that left.

You are then asked the ordinary external-change question. With unsaved edits it reads "«Report.md» changed on disk while you have unsaved edits."; with no unsaved edits, "«Report.md» was modified outside the app." The buttons are Reload and Keep My Version.

Keep My Version is the one to pick if the returning file is a stale copy. The text in front of you becomes the version that counts, the tab is marked unsaved, and the decision sticks — quit, reopen, and you will not be handed back the version you just rejected. Save the tab afterwards and the file on disk finally matches what you chose.

Tabs that come back marked "(missing)"

If you quit or crash while a tab has no file behind it, the next launch puts your session back: every tab that was open, in the same order, with the same tab selected and your unsaved text where you left it.

A tab whose original file is no longer there is kept rather than dropped. It comes back titled Report.md (missing), with nothing on disk behind it, and ⌘S on it opens Save As. It reads as missing rather than quietly turning into an untitled document, and that distinction matters when you are working out what happened: the title still tells you which file this text used to be.

Separately, if the previous run ended badly, our auto-recovery safety net brings back work from tabs that are no longer open, as *filename tabs. Nothing to dismiss and nothing to pick from: the work is simply there when the window opens. Go through those tabs and save out whatever you want to keep.

Moving a file to the Trash from inside the editor

File ▸ Move to Trash… does the deliberate version of all this: a considered trip to the File menu, which is about the right amount of ceremony for throwing something away. Like the other disk-only items in that part of the menu, it becomes available as soon as the active tab has a file on disk behind it.

Two related behaviours are worth knowing. First, a file in the Trash counts as missing either way: trashing it from this menu and trashing it anywhere else on your Mac look the same from inside the editor. Second, if you close a tab with unsaved work and choose Don't Save, a glass panel appears at the bottom of the window for a few seconds reading "Discarded «Report.md» — restore?" with a Restore button. That is a genuine second chance at work you have just thrown away, so take it while it is on screen.

Tuning the file monitor to your setup

Deletion detection is on by default and lives in Settings ▸ File Monitor (⌘,), alongside the switch for watching files at all, the change mode, how quickly you are told about a change, and whether you are warned when a change lands on top of unsaved edits. The change mode — Ask (the default), Auto-Reload or Never — governs modifications, not deletions, and a clash with unsaved edits always asks you first whatever the mode says.

Most people leave detection on and never think about it again: being told the moment a file goes is what makes everything above so straightforward, and on a quiet day it stays out of your way entirely. If a network volume you know well is producing warnings you know to be false, you can switch detection off in the same panel and switch it back on when you are done with that share. Our auto-recovery safety net carries on holding your unsaved work whatever the switches say, so your text is looked after either way.

Note

The file-monitoring controls are always a click or two away, in both of the places you are likely to be when you want them: the status-bar badge menu, right next to the badge that is telling you something, and Settings ▸ File Monitor.

A safe order of operations when a whole folder disappears

When a checkout or a clean-up takes out several files at once, the prompts arrive one at a time as you visit each affected tab. Work through it in this order.

  • Answer Keep in Editor on every affected tab first. Visit each one; the question is waiting there. Do not close anything yet.
  • Then save each one out, to a scratch folder, before you touch the source tree again.
  • Do not use the bulk closes as a tidy-up. "Close Saved Tabs" means tabs with no unsaved changes — which is not the same as tabs that have a file on disk.
  • Only then work out why. A branch switch, a clean target, a sync client or a script with a broad delete are the usual suspects. With every rescued tab already written out to a scratch folder, you can take that investigation at your own pace.

Troubleshooting

The file vanished and I was never told

Check three things in order. Deletion detection may be switched off in Settings ▸ File Monitor. Watching may be off entirely. Or the tab may be an untitled document or a recovery tab, which does not have a file on disk behind it yet — save it once and it is watched from that moment on, badge and all. On a network volume the warning can take a little longer to reach you than it does on a local disk.

The sheet only appeared when I clicked back onto the tab

That is deliberate. A question about a background tab waits on that tab until you go to it, so you are never interrupted mid-sentence by something that happened in a different document.

Save appears to do nothing

⌘S on a tab that is not tied to a file opens the Save As panel, so the shortcut already in your fingers still gets you a saved document. Give it a name and a folder and the tab has a home again — and the disk-related items in the File menu come to life at the same moment.

I closed the tab by accident

If you were offered Save / Don't Save / Cancel and chose Don't Save, look at the bottom of the window: the restore panel is live for a few seconds only. If the app was killed rather than quit cleanly, check the tabs that reopen at next launch — our auto-recovery safety net brings that work back on its own, so look there before you retype anything.

The file came back but with the wrong contents

You will be asked, because a file that returns always asks first. Choose Keep My Version to keep what is in front of you, then save. If a reload cannot be completed for any reason, your text is left exactly as it was rather than half-replaced.

I moved the file rather than deleting it

A move out of the folder looks exactly like a deletion from inside the editor, and you get the same sheet. To move a file deliberately, use File ▸ Rename File…, which opens a save panel and can write to any destination — an intentional move and rename in one step, and it asks you first if there is unsaved work in the tab.

Getting the most out of the rescued copy

Once the text is back on disk, a few minutes of housekeeping turns a rescue into an ordinary working file again.

  • Give it a name that says what happened. Something like Report-rescued.md in a scratch folder keeps it clearly apart from whatever the source tree may put back later. Rename it to the real thing once you know which copy you want to live with.
  • Put two copies side by side before you decide. If the original comes back, or a colleague has their own version of it, save both as files and open them in our comparison view. It shows you what changed line by line and leaves both files exactly as they are, so you can choose with the differences in front of you instead of from memory.
  • Freeze the state you have just rescued. File ▸ Save a Copy As… (⌥⇧⌘S) writes a second copy and leaves the tab pointing where it is — a cheap way to bank the text you have recovered before you start editing on top of it.
  • Let the extension do its work. The Save As panel arrives with an extension already matched to the document by our advanced language identifier, so the rescued file reopens looking exactly as it does on screen right now, with the same colouring you were reading before the file went.
  • Trust the tabs you have open. Watching follows the file, so a tab with a file behind it is looked after while you work — which is why you found out in time to read this at all. Save the rescued text once and it is watched from that moment on, badge and all.
  • Keep the star honest. While a document is unsaved, the leading * is the one thing to look at. Clear the stars before you close the window and you know that everything on screen is also on disk.

Then open the saved file once and read the first and last few lines. It takes seconds, and it is the difference between believing your text is safe and knowing it.

Frequently asked questions

My file was deleted while it was open. What can I get back?

Everything that is on screen. Note My holds on to the text in the open tab, keeps a private copy of it against a crash or a forced quit, and lets you write it out under any name and into any folder you like. Choose Keep in Editor, then Save As, and the rescued text is an ordinary file again. The original file on disk is a matter for the Trash or your backup system.

If I quit now, will my text still be there tomorrow?

Yes. Our auto-recovery safety net holds a private copy of unsaved work, and the next launch puts your session back with that text where you left it. The tab returns titled filename (missing), with no file behind it, and ⌘S on it opens Save As.

A git checkout removed the file. Is that different?

It is handled in exactly the same way, as are a clean script, a sync client and a drag to the Trash. As far as the editor is concerned, the file simply stopped being there, and your text stays in front of you. If the checkout puts the file back, you are always asked before anything replaces that text, so you get to choose between the returning file and what you have on screen.

Why does the tab still show a star after I chose Keep in Editor?

Because the text on screen is now the copy that counts, and the star is your reminder that it still wants a home on disk. Save it anywhere and the star clears. It is a leading * on the tab title, and it is not the same as the orange dot, which means "changed on disk".

Can I stop the deletion prompt appearing?

Yes, in Settings ▸ File Monitor, where it is on by default. Your unsaved work is held safely either way, because our auto-recovery safety net keeps it whatever the switches say. Most people leave detection on all the same: finding out while the text is still in front of you is what makes it so easy to rescue.

Does any of this involve a server?

All of this happens on your Mac, and only on your Mac. Nothing about your file — its name, its contents, or where it lived — is uploaded anywhere, there is no account to sign into, nothing is tracked, and your recovery copies stay on the machine where you can get at them.