Talk:FAQ:Errors on opening or recovering an Audacity project

From Audacity Development Manual
Revision as of 11:46, 27 May 2017 by PeterSampson (talk | contribs) (WIP)
Jump to: navigation, search
This page deals with errors that you may encounter when opening or recovering an Audacity project. Most of these errors are caused by malformed or broken .aup files.
Peter 26Apr16: images of the error messages may be useful in their H2 sections.

Contents

  1. Errors: "not well-formed (invalid token) at line x" or "reference to invalid character number at line x"
  2. Attempting to import an Audacity Project


Errors: "not well-formed (invalid token) at line x" or "reference to invalid character number at line x"

These error messages usually mean that when reopening the AUP project file normally, Audacity finds an unexpected non-English, accented or control character at the line quoted in the error message. There are three main causes of this.
  • The project contains imported files whose metadata (like artist or genre) contains control characters meant for use by another player application. This mostly occurs with iTunes files on Mac where the project was created in an older version of Audacity. This usually creates the "(invalid token)" error.
  • The project contains imported files whose metadata contains symbols that Audacity cannot display. This may create either the "(invalid token)" or "invalid character number" error
  • The project was saved containing non-English or accented characters using an old ANSI build of Audacity for Windows. ANSI builds are not properly Unicode aware, so do not support non-English or accented characters.
If Audacity or the computer crashed, Audacity will try to recover the project from its AUTOSAVE file, but the crash may have created a redundant line near the end of the file that triggers the token error. Very occasionally, the AUP file may become corrupted by one or more redundant lines, giving a token error even if there was no apparent crash. To correct this, see remove redundant lines in an AUTOSAVE or AUP file.
  • Bill 11May12: What are we talking about in the box below? Is it when Audacity crashes without completely writing the AUP? I've seen one of those on the forum where the AUP file just stopped without closing a number of tags. "In some cases"? Doesn't Audacity wait to delete the temp files before it completes writing of the saved file? What does "if this does not happen" mean?
  • Gale 11May12: Bill, thanks for picking up on this. It is intentionally vague. Yes, this is usually when there is a crash on saving, but I have seen a number of cases where there was no (reported) crash; Audacity just writes an .aup file that terminates prematurely in nulls (or is even completely nulls). So this latter case is really moonphase saving problems as per what used to be called bug 137.

    If the crash occurs at the last step of saving (when (re)writing the .aup itself) this will almost certainly result in "invalid token" if the .aup is opened. The question is not I think what happens to the temp files - if the project was never saved before, the temp files (I believe) are moved to a newly created _data folder for the project in the early stages of saving. The question is whether the autosave file that recovery depends on is retained until the .aup file is correctly written.

    From user reports I have seen, a crash that leaves a corrupted .aup file will sometimes initiate a crash recovery and sometimes not, possibly because there is no proper test of whether the .aup is valid before deleting the autosave file (that is speculation). This behavior is probably one of a number that should be follow-up moonphase bugs branching out from bug 137.

  • Bill 11May12: Tried rewriting it.
    • Gale 21Nov13: Added steps for removing NULL line at end of autosave file and suggested there that this may help correcting an AUP file corrupted for unknown reasons. Replaced the advice div with a note div at the end of this FAQ on other options if all else fails.

Solution for error caused by control characters

  1. Make a copy of the AUP project file and open it in a text editor. You can use the default Notepad on Windows or TextEdit on Mac, but in a few instances these could change the AUP file in such a way that Audacity could no longer open it. We recommend instead Notepad++ for Windows and Brackets or BBEdit for Mac.
  2. Turn word wrap off in the menus (or in TextEdit, drag the window horizontally so that lines do not wrap).
  3. In the line indicated in the error message, look for one of these:
    • projname=
    • name=
    • value=
    • title=

    then remove all characters inside the quotation marks that follow which are not a number or an A to Z letter. You could also change those characters to a number or A to Z letter. For example, a string of control characters you would want to remove or change might start with &# followed by four numbers and a semi-colon, such as &# 0 0 1 3 ;.

  4. Save the changes to the .aup file.
  5. If you re-open the project and an error occurs at another line, repeat the steps above in the new line indicated in the error message.
Here is a real-world example of a corrupt line in the GENRE tag in a project where "Drama" and "Comedy" were incorrectly separated using the control character for a horizontal tab, also missing the closing semi-colon:

<tag name="GENRE" value="Drama &# 0 0 0 9 Comedy"/>

And the same line corrected so that the two words can be read into the project:

<tag name="GENRE" value="Drama, Comedy"/>

"Drama 0009 Comedy", though meaningless, would also enable the project to be opened correctly.
Advice

If you had to rename "projname" in the AUP file, rename both the AUP project file and the corresponding _data folder so that they have the same name as "projname" in the AUP file.


Solution to correct an AUP file created in an ANSI version of Audacity, preserving non-English characters

  1. Make a copy of the file
  2. Open the file in Notepad++ (a free text editor that supports UTF-8 encoding of Unicode characters)
  3. Choose Encoding > Convert to UTF-8 without BOM
  4. Save the changes to the file.
Gale 30Jun15: Commenting this out because AUTOSAVE files are now binary and would need converting to text. If we still have time to fix this for 2.1.1 I will do so.
  • Gale: later - done and uncommented - a nightmare for users if they have to convert the AUTOSAVE file. One has already had to, hence why I wrote this. Perhaps the conversion steps could move to Wiki but that is not very friendly.

Solution to remove redundant lines in an AUTOSAVE recovery file or AUP file

If you have an AUP file with a token error not solvable by deleting invalid characters, try checking for and deleting any empty lines or duplicate </project> lines as per steps 5 through 8 below.
  1. Find the autosave file. It will be in an "AutoSave" folder in Audacity's folder for application data as follows:
    • Windows 10/Windows 8/Windows 7/Windows Vista: Users\<username>\AppData\Roaming\Audacity\
    • Windows XP: Documents and Settings\<username>\Application Data\Audacity
    • OS X/macOS ~/Library/Application Support/audacity/
    • Linux: ~/.audacity-data/ .
  2. Make a copy of the AUTOSAVE file as a backup and move the copy somewhere else such as your Desktop.
  3. If the AUTOSAVE file was created by Audacity 2.1.1 or later, it must be converted to XML format before it can be edited in a text editor. Follow the steps to convert the AUTOSAVE file to XML then return to step 4 below.
  4. Open the AUTOSAVE file in a text editor like Notepad (Windows) or TextEdit (Mac).
  5. Turn word wrap off in the menus (or in TextEdit, drag the window horizontally so that lines do not wrap).
  6. Go to the line indicated in the error message. If you had been recording, the last line above it will probably look like </recordingrecovery>.
  7. We need to delete the entire line. It may be a long line containing only empty spaces or it may have </project> at the end of all the spaces. Hold Shift and press Down to select the entire line before pressing Delete. Ensure this leaves you with a final line that contains only </project>. Ensure this is the only line that contains </project>.
  8. Save the changes to the file.

Converting the AUTOSAVE file to XML

Advice

Exit Audacity before attempting these steps.

Windows:

  1. In the AutoSave folder, right-click the AUTOSAVE file and choose "Cut".
  2. Go to the folder Audacity is installed in, such as "C:\Program Files (x86)\Audacity", then right-click in empty space and choose "Paste". Provide the administrator password if asked.
  3. Open an administrator command prompt. On Windows XP, Vista or Windows 7, click Windows Start, go to All applications > Accessories, then right-click the Command Prompt shortcut and select "Run as Administrator". Or see instructions for Windows 8.
  4. Assuming the prompt in the command window shows some location in C:\ and Audacity is installed in some location in C:\, type "cd" (without quotes) then a space. If Audacity is on some other drive than the prompt indicates, type the name of that drive letter and a colon (such as D:), press Enter, and then type "cd" (without quotes) then a space.
  5. Go up one level in Explorer then drag the icon for the Audacity installation folder into the command window. The path "C:\Program Files (x86)\Audacity" (or whatever it is) will appear. Press Enter to change the prompt to the path you dragged in.
  6. At the end of the path, type "audacity" (without quotes), a space, then "/d" (also without quotes), another space, then drag the AUTOSAVE file into the command window. Here is what an example should look like:
    C:\Program Files (x86)\Audacity> audacity /d "C:\Program Files (x86)\Audacity\My Project - 2015-07-01 14-12-35 N-2.autosave"
  7. Press Enter. You can see in Explorer that the AUTOSAVE file has been updated.
  8. Now you can cut the AUTOSAVE file from the Audacity installation folder, and paste it into the AutoSave folder. Now you can make corrections to the file in a text editor.

Mac OS X/macOS:

  1. In the AutoSave folder, right-click or Control-click the AUTOSAVE file and choose the option to Copy.
  2. Go to the folder Audacity.app is installed in, such as /Applications/Audacity, hold Command and Option then press V to move the AUTOSAVE file alongside Audacity.
  3. Right-click over Audacity.app then choose "Show Package Contents".
  4. Open the "Contents" folder then the "Mac OS" folder.
  5. Open a Terminal then drag the Audacity file in the "Mac OS" folder into the terminal to display the path to that Audacity file.
  6. Then at the end of the file path, type a space, "-d" (without quotes) and another space then drag the AUTOSAVE file into the Terminal.
  7. Press Enter to convert the file. You will see a message that the file has been decoded successfully.
  8. In the "Mac OS" folder, right-click or Control-click the AUTOSAVe file and choose the option to Copy.
  9. Go to the "AutoSave" folder, hold Command and Option then press V to move the converted AUTOSAVE file back into the AutoSave folder. Now you can make corrections to the file in a text editor.

GNU/Linux:

  1. Open a terminal.
  2. Assuming Audacity is installed, type "audacity -d" (without quotes) then a space, then type the path to the AUTOSAVE file (or drag the AUTOSAVE file into the terminal). Here is an example:
    audacity -d "home/al/.audacity-data/AutoSave/My Project - 2015-07-01 14-12-35 N-2.autosave"
  3. Press Enter to convert the file. You will see a message that the file has been decoded successfully. Now you can make corrections to the file in a text editor.
If none of the above helps to correct the invalid token error, you can:
  • Ask for help on the Audacity Forum and attach the AUP or autosave file.
  • Try to recover the project manually, if it is an unedited recording.


Attempting to import an Audacity Project

Peter 26May17: Sketchy draft, as a placeholder ...

"`aup" is an Audacity Project file.

Use the 'File > Open' command to open Audacity Projects" .