Edit: This tutorial is often updated to add information and make clarifications.

Although this is written based on Writer .odt files, it also works for Calc files and presumably all AOO files, and for .docx files. If you are trying to recover a .ods or .xlsx file then follow the .odt instructions. If you are trying to recover a .xls file then follow the .doc instructions.

It will also work for Mac users though you will need to find a Mac un-delete program.

If you have lost a file, or you have a file which is full of ######, or you have a file which is corrupted beyond repair; and you want to un-delete the temporary files then STOP USING THE PC and DO NOT POWER IT OFF until you have recovered the file so as to maximise your chance of success.

The post looks complex but it is actually pretty simple - just work slowly through it. If you get stuck ask someone with better computer skills to help you, or print the instructions (File > Print ...) and take the instructions and your PC to a PC repair shop.

Do you have a Solid State Disk (SSD) in your PC? If so, your chances of recovering a deleted file are poor.

Modern PCs are increasingly being equipped with Solid State Disks (SSD) because SSDs are so much faster than old fashioned rotating hard disk drives. When you have an SSD, the Operating System works silently in the background to set all the bits in deleted files to zero so, unfortunately, you may not find that many deleted temporary files! The Operating System does this because the Operating System must set all bits to zero before it can write new data to the SSD. Setting the bits to zero in the background therefore speeds future writes because the "setting bits to zero" work has already been done.

If you have a separate rotating disk you can setup AOO to write its temporary files to that disk with Tools > Options > OpenOffice > Paths ..., and set the Temporary files path to the rotating disk. AOO will now operate very slightly slower but it should be imperceptible except for very large files (many MBytes) or for files with many large images.

Many of the required files are hidden files ...

... so before you begin you must switch on being able to see hidden files by:

1 Start > Control Panel > Folder Options > View ...

2 Select Show Hidden files, folders and drives

If you have not done this you will not be able to see the temporary files folder or the temporary files inside it. In Windows 10, go File Explorer > View (Ribbon tab) > Options ..., to open the Folder Options/File Explorer Options window.

You MUST switch on Show Hidden Files and Folders or you will not be able to see the temporary folder or the files inside it

First look for previous versions of the file itself

Say you have lost ...My documents\fred.odt (or fred.doc or fred.rtf etc). Before trying to get back temporary files, use Recuva to see if you can get back previous versions of ...My documents\fred.odt (or fred.doc or fred.rtf) by looking for deleted fred.odt (or deleted fred.doc or fred.rtf etc) in ...My Documents\ (or in whichever folder the file fred was located).

Did you have AutoRecovery set to ON?

Check if AutoRecovery was set to ON by Tools > Options > Load/Save > General ...

If so, and you were editing fred.odt, look in C:\Users\xxxxxx\AppData\Roaming\OpenOffice\4\user\backup\ for fred.odt_0.odt. This is the file as it was when it was last saved by AutoRecovery. You could also look for deleted versions. " xxxxxx " here and below is your username on your PC.

Did you have Create a Backup copy set to ON?

Check if Create a Backup copy was set to ON by Tools > Options > Load/Save > General ...

If so, and you were editing fred.odt, look in C:\Users\xxxxxx\AppData\Roaming\OpenOffice\4\user\backup\ for fred.bak. Open fred.bak with Writer (or rename it to fred.odt). This is the file as it was when you opened it for editing. You could also look for deleted versions.

No luck so far? It's time to look for temporary files.

Looking for temporary files

When you open a file for editing, Writer creates temporary files and it is these temporary files you need to look for. Writer deletes these temporary files when you close the document and/or when Writer closes properly. If Writer crashes, or your PC crashes, these files are often not deleted and can easily be recovered. If they have been deleted, you just need to un-delete them.

When you open an existing .odt file, Writer takes a copy of the .odt file as it was when opened and saves the copy of the .odt file as a temporary file with a name like sv2ju21c.tmp. This is the file you are trying to recover. When you get such a file just rename it to a .odt file and try to open it.

If you save a .odt file while you are editing it and continue to edit it, Writer updates the temporary file above to be the same as the newly saved file.

If you create a new document from scratch Writer creates an empty temporary file with nothing in it, so there is nothing to recover unless you had AutoRecovery set to ON and an AutoRecovery save had taken place.

Temporary files inside folder C:UsersJohnAppDataLocalTempsv3i2d1f.tmp

The first file is the .odt file as it was when you opened it - this is the one you wantThe second file is a binary file - ignore it - it is to do with displayingThe other files are copies of the images which have been paged out of memory. You do not need them as all the images are in the first file. If you have added images then some may be here

The following is based on Windows 7 but other versions of Windows should be very similar.

Mac and Linux

If you are running Mac or Linux, it should still be very similar. All you need to do is to check which paths Writer uses by Tools > Options (Preferences for Mac??) > OpenOffice > Paths .... If you are in doubt, open a .odt file (or create a new one or edit a .doc file - whatever it was you were doing when you lost the document) and check to see where the temporary files go and what they are called. Then search in that folder or folders for deleted temporary files for your lost document where the deleted files will have similarly formed names to those you found when doing the check. You will a need Mac or Linux unzip utility and a Mac or Linux un-delete utility.

USB memory stick or second disk

It is better (but not essential) to un-delete the file(s) to a different disk from the disk on which the original file was created or saved because, if you un-delete to the same disk, you run the risk overwriting the very files you are trying to get back! It is better, but not essential, to recover them to a USB memory stick, or to a second disk if you have one.

1. Looking for temporary files which are still there and have not been deleted

1a. If your PC or Writer crashed ...

... you may find that the temporary files are still there, so navigate to the Temp folder (it is specified in Tools > Options > OpenOffice > Paths ...) and see if you can see them. Sort the files in alphabetical order and rename the first file with a name like sv2ju1mk.tmp to fred.odt and try to open it with Writer.

If you cannot see any, then Writer has deleted them. You now need to un-delete them. Act quickly - they risk being overwritten the longer you leave it..

1b. Did you have AutoRecovery set to ON?

If you had AutoRecovery set to ON, then Writer should have automatically fixed your file for you. If Writer does not or cannot recover your file, follow the instructions below and check to see if the AutoRecovery files are still there. If there are no AutoRecovery files then look for deleted the AutoRecovery files. (Note - check to see if AutoRecovery was on by Tools > Options > Load/Save > General ...)

1c. Did you have Create a backup copy set to ON?

If you had Create a backup copy ... set to ON, look in the Backup folder for a file called fred.bak, where your file is fred.odt. Open fred.bak with Writer (or rename it to fred.odt). (Check to see Create a backup copy was ON by Tools > Options > Load/Save > General ...)

2. Looking for temporary files which have been deleted

If 1a, 1b and 1c failed you have to look for deleted temporary files. The method you use depends on what type of file you were editing, namely:

- whether it was an existing .odt file saved on your PC (or .docx file); - a file which you had never previously saved; or - a .doc file.

From what I can gather, Writer handles .docx files in the same way as .odt files so, if you are recovering a .docx file, follow the instructions for .odt files.

2a. Recovering .ODT files which have previously been saved - also works for .DOCX files

In this case, you were editing a .odt file like fred.odt (or adocx file like fred.docx).

You are looking for files with names something like C:\Users\xxxxxx\AppData\Local\Temp\sv2ju1mk.tmp\sv2ju21c.tmp. Note that it is very unusual for a folder to be called C:\Users\xxxxxx\AppData\Local\Temp\sv2ju1mk.tmp, with a " . " in the folder name, but this is what Writer does. You will therefore be looking for files called something like C:\Users\xxxxxx\AppData\Local\Temp\sv2ju1mk.tmp\sv2ju21c.tmp where " xxxxxx " here and below is your username.

Converting a found temporary file back to a .odt or .docx file

If you manage to find and undelete a file like ...sv2ju21c.tmp, you need to check if it is a .odt or .docx file as it could be a graphics file.

The easiest way to check if it is a .odt or a .docx file is to try to unzip the file. The easiest way to unzip it is to rename it to sv2ju21c.ZIP and double click it. If it opens a window showing files then it must be a ZIP file. If it does not it is a graphics file or a damaged file. If one of the files in the window is called content.xml it is a .odt file, so now rename it sv2ju21c.ODT and open it with Writer. If the window has a folder called Word it is a .docx file so rename it to sv2ju21c.DOCX and use Writer to open it.

You should get back the complete fred.odt (or fred.docx) file as it was the previous time it was saved and it should have all the images, both those already in the document when you opened it and all the images added since. You do not get any text added since the file was last saved.

If you had AutoRecovery set to ON then also see 3. Getting back AutoRecovery files when AutoRecovery has been set to ON below as you may also be able to recover some of the AutoRecovery files as well or instead.

3. Getting back AutoRecovery files when AutoRecovery has been set to ON

The following methods only work if you had AutoRecovery set to ON.

Note: you set AutoRecovery to ON by Tools > Options > Load/Save > General ... The Backup folder location is specified in Tools > Options > OpenOffice > Paths ..., and the default is C:\Users\xxxxxx\AppData\Roaming\OpenOffice\4\user\backup\.

3a. Recovering the AutoRecovery file for an existing [i][b]fred.ODT which was being edited - it should also work for fred.DOCX files[/i][/b]

If you were editing fred.odt, then Writer creates an AutoRecovery file called fred.odt_0.odt in the Backup folder. The default backup folder is C:\Users\xxxxxx\AppData\Roaming\OpenOffice\4\user\backup\ so you are looking for files named C:\Users\xxxxxx\App\Data\Roaming\OpenOffice\4\user\backup\fred.odt_0.odt where " 0 " is a zero.

First, navigate to the Backup folder and look for existing files like fred.odt_0.odt.

Second, if there are no fred.odt_0.odt files in the Backup folder, then use Recuva and try to find a deleted version of fred.odt_0.odt. If you do manage to find it, fred.odt_0.odt will have the entire contents of the document as saved at the AutoRecovery time it was created.

3b. Recovering the AutoRecovery file for a new document which has never been saved

If you are editing a new file and you have never saved it, Writer gives the file the name Untitled1.odt while you are editing it but does not save it. When Writer creates an AutoRecovery file, Writer creates a file called untitled_0.odt in the Backup folder as C:\Users\xxxxxx\AppData\Roaming\OpenOffice\4\user\backup\untitled_0.odt where " 0 " is a zero.

First, navigate to the Backup folder and look for untitled_0.odt.

Second, if it is not there, then use Recuva and try to find a deleted version of the file. If you do manage to find it, it will have the entire contents of the document as saved at the AutoRecovery time it was created.

3c. .doc files. Recovering the AutoRecovery file for an existing fred.DOC which was being edited

Assume you are editing fred.doc and you have AutoRecovery set to ON. When Writer does an AutoRecovery save, Writer creates a temporary AutoRecovery file for fred.doc called fred.doc_1.odt and saves it in the Backup folder. The file will be named C:\Users\xxxxxx\AppData\Roaming\OpenOffice\4\user\backup\fred.doc_1.odt. Writer deletes this AutoRecovery file when you save the .doc file and/or when you close Writer.

When you edit a .doc file AND you have AutoRecovery ON, Writer creates a copy of the file in the Backup folder

First, navigate to C:\Users\xxxxxx\AppData\Roaming\OpenOffice\4\user\backup\ and look for fred.doc_1.odt, where fred is the name of the file you were editing. If your PC or Writer crashed, you may be lucky and still find fred.doc_1.odt there.

Second, if you do not see fred.doc_1.odt, then use Recuva and look for deleted versions of it.

There are some more detailed explanations in the following posts which may be useful:

1 Do not be too hasty when shutting down your PC, or slamming the laptop lid shut, or pulling the USB memory stick out. AOO continues to write data to the file and to the profile for several seconds (many on a slow network) after the blue dotted line has finished crossing the screen. You must not shut down the PC or remove the USB stick while this writing is taking place.

2 If you save your file to a USB memory stick be sure to eject the USB memory stick safely. On Windows 7, right-click the USB icon in the System Tray (bottom right, by the time) and choose Eject.

3 Always set AutoRecovery to ON - this saves a copy of the file every few minutes while you are working on it - it protects you against things like power cuts, OS freezes etc. Do so by Tools > Options > Load/Save > General ...

4 Always ?? set Create A Backup copy to ON - this keeps the previously saved version of the file fred.odt as fred.bak in the Backup folder. Do so by: Tools > Options > Load/Save > General ... The Backup folder location is shown by Tools > Options > OpenOffice > Paths ... You may need to switch on Show hidden files (Control Panel > Folder Options > View ...) to be able to see the folder and its contents.

Why the ?? ? Because you should remember that highly_personal.bak will still be in the Backup folder long after you have deleted highly_personal.odt.

5 ... and, of course, always take a daily backup of all important files and store them somewhere safe. A cheap USB memory stick is infinitely better than nothing. In an emergency, or if you need a very quick backup, just email yourself a copy of the file!

Remember, it is not a case of "if my disk fails ..." or "if I lose my file". It is a case of what do I do "when my disk fails ..." and "when I lose my file ...". You can download free backup utilities which will back up your hard drive daily so that you will never lose more than 24 hours work - I have used Cobian from http://www.cobiansoft.com/index.htm for many years and have never lost a file despite having disk crashes and lightning which destroyed both my PC and hard drive.