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

From Audacity Development Manual
Jump to: navigation, search



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

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.
Warning icon

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.

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

Warning icon

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