FAQ:Errors on opening or recovering an Audacity project

From Audacity Development Manual
Revision as of 13:01, 9 August 2017 by PeterSampson (talk | contribs) (Solution to remove redundant lines in an AUTOSAVE recovery file or AUP file: expunging XP)
Jump to: navigation, search
Gale 20Jun16: ToDo-1 This page seems an orphan.
  • The FAQ Why do I get "Error: not well-formed (invalid token) at line x?" ignores this page, linking to the now redundant Error:_not_well-formed_(invalid_token)_at_line_x.
  • The FAQ "Why do I get "Error importing" when opening an AUP file?" ignores the information on this page.
  • Perhaps we want a single, brief generic FAQ about errors opening projects, linking here.
    • Peter 20Jun17: Yes, it's only linked from my user pages and James pdf page right now. I got sidetracked doing other work. I'd be quite happy to see it as a link from a "brief generic FAQ about errors opening projects". I was sort of leaving that for you as you do most of the FAQ work - and If I recall I was awaiting the nod from you as to whether this page was ok or not. I'm thinking it could be quite good to shorten that but of the FAQs.
      • Peter 20Jun17: I seem to recall that we started this page as a landing page for error message help buttons in the app.
      • Gale 20Jun17: I look at the FAQs close to release because they quite often have errors and omissions. Yes you can leave it to me if you like. It may be close to release before it gets changed.
        • Peter 20Jun17: I'm happy to leave that to you Gale - you understand the whys and wherefores of the FAQs better that the rest of us.

          Any time before release/freeze will be fine (we have the P1 as a marker). And even then if you don't have time we would still have this as an orphan page and the FAQs in full as they are now - and Steve can still link his error message help buttons to here.


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. Error Opening Project: not well-formed (invalid token) at line x
  2. Error Opening Project: Reference to invalid character number at line x
  3. Error Importing: Aup is an Audacity Project file. Use the File > Open command
  4. Error Opening File or Project: File may be invalid or corrupted
  5. Error Opening Project: mismatched tag at line x
  6. Other errors opening project


Error Opening Project: not well-formed (invalid token) at line x

This error message usually means 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 two main causes of this.
  • The project contains imported files whose metadata (like artist or genre) contains control characters. This mostly occurs with iTunes files on Mac where the project was created in an older version of Audacity.
  • The project contains non-English or accented characters and was saved in an old ANSI (non-Unicode) build of Audacity for Windows, or saved as ANSI in a text editor (this can happen if saving in Notepad on Windows). ANSI encoding cannot represent 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 (or 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 saved as ANSI, 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 (old versions of Notepad++ may refer to this as 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: Users\<username>\AppData\Roaming\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 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 and Windows 10.
  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 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 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.

Problem still there? It probably means there is a specific problem with the syntax of the tags in the AUP file. Copy the AUP file to another location, then open the file in Notepad++ for Windows and Brackets or BBEdit for Mac and examine if the tags of the file enclosed in angle brackets <  > are consistently open and closed and are complete.


Error Opening Project: Reference to invalid character number at line x

This error message usually means 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 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.

Solution:

  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 ;.

    For symbols there will usually be five characters between the &# and a colon.

  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 "Country" and "Western" were incorrectly separated using the control character for a horizontal tab, also missing the closing semi-colon:

<tag name="GENRE" value="Country &# 0 0 0 9 Western"/>

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

<tag name="GENRE" value="Country, Western"/>
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.



Error Importing: aup is an Audacity Project file. Use the File > Open command

This error usually occurs because you have attempted to open an Audacity project by using the Import command (which is reserved for audio files).

Instead, you should always use File > Open... to open an AUP (Audacity Project) file.

If you see "Error Importing" even when using File > Open..., this usually means the AUP file is seriously damaged, has been encoded other than as UTF-8 without BOM, or only contains NULL (zero) data.

NULL contents

The contents are NULL and unusable if you open the AUP file in a text editor like Notepad or TextEdit (on Mac) and see empty contents despite the file being a non-zero size. The AUP file is saved last, so a NULL AUP file can occur if you shut down the computer or close the lid on a laptop before the project is completely saved. Be sure to wait until the Audacity Status Bar says the project is saved, or until all project save progress dialogues have closed, before shutting down the machine.

If the AUP file appears empty, try to use any backup you created, such a different AUP file for an earlier stage of the project, or an exported WAV file. Failing this, you can try manual recovery of the project's _data folder, but this only works for unedited recordings.

File not saved as UTF-8 without BOM

Using Notepad on Windows to save an AUP file containing Unicode characters as UTF-8 will create this problem because Notepad adds a BOM. To solve it, open the file in Notepad++, choose Encoding > Convert to UTF-8 then save the file. Old versions of Notepad ++ may refer to the required command as Convert to UTF-8 without BOM. If the problem occurred after editing the AUP file in TextEdit on Mac, resave the file as text in Brackets or BBEdit.


Error Opening File or Project: File may be invalid or corrupted

This error is seen if the file is completely empty (0 kB) or for some cases of partial corruption of the file syntax. If the file is 0 kB, try to use any backup you created, such a different AUP file for an earlier stage of the project, or an exported WAV file. Failing this, you can try manual recovery of the project's _data folder, but this only works for unedited recordings.

If the file is non-zero size, you can try backing up the AUP file to another location, then open the file in Notepad++ for Windows (or Brackets or BBEdit for Mac) and examine if the syntax of the file is consistent and if the file is complete as expected. Compare with a known good AUP file to see what the AUP contents should look like.

Error Opening Project: mismatched tag at line x

This error usually means that for some reason, an opened tag in the XML did not have the same name as the tag that was opened, or a nested tag (inside the tag) was not closed correctly.

Examples:

Wrong - the closing tag is "tag" instead of "tags" to match the tag that was opened:

<tags>
   <tag name="ARTIST" value="Elton"/>
</tag>


Wrong - the closing "/" after "Elton" is missing:

<tags>
   <tag name="ARTIST" value="Elton">
</tags>


Correct!

<tags>
   <tag name="ARTIST" value="Elton"/>
</tags>


Other errors opening project

There are a number of other errors that you might see relating to the syntax of the AUP file not being quite correct, such as:

  • unclosed token at line x (for example, the final </project> tag is missing its ending ">"
  • no element found at line x (for example, the final </project> tag is missing in an otherwise correct file)
  • junk after document element at line x

The best advice in these cases is to examine the line quoted carefully, and don't manually edit the AUP file unless it is unavoidable.