Managing Files and Your Collection
检查你的集合
Checking Your Collection
偶尔检查集合文件是否有问题是个好主意。你可以通过“工具”>“检查数据库”菜单项执行此操作。检查数据库可以确保文件没有损坏,重建一些内部结构,并优化文件。
It is a good idea to occasionally check your collection file for problems. You can do this via the Tools>Check Database menu item. Checking the database ensures the file has not been corrupted, rebuilds some internal structures, and optimizes the file.
检查数据库时,还会重新生成标签列表。当你删除单个牌组或卡片时,Anki 不会更新已使用标签的列表,因为这样做效率很低。如果你想从列表中清除不再使用的旧标签,检查数据库是一种方法。
When you check the database, your tag list is also rebuilt. When you delete individual decks or cards, Anki does not update the list of used tags, as it's inefficient to do so. If you want to clear old tags out from the list that are no longer in use, checking your database is the way to do it.
请注意,Anki 将每两周自动优化你的集合一次。此优化可确保集合运行良好,但在自动优化时不会检查错误或重新生成标签列表。
Please note that Anki will automatically optimize your collection once every 2 weeks. This optimization ensures the collection performs well, but it does not check for errors or rebuild the tag list when automatically optimizing.
文件位置
File Locations
Windows 上,最新的 Anki 版本将你的 Anki 文件存储在你的 appdata 文件夹中。你可以通过打开文件管理器并在位置字段中键入%APPDATA%\Anki2
来访问它。旧版本的 Anki 将你的 Anki 文件存储在 Documents
文件夹中名为 Anki
的文件夹中。
On Windows, the latest Anki versions store your Anki files in your appdata folder. You can access it by opening the file manager, and typing
%APPDATA%\Anki2
in the location field. Older versions of Anki stored your Anki files in a folder called Anki in yourDocuments
folder.
Mac 上,较新的 Anki 版本将其所有文件存储在~/Library/ApplicationSupport/Anki2
文件夹中。Library 文件夹默认情况下是隐藏的,但可以在 Finder 中显示,方法是在单击 前往菜单的同时按住选项键。如果你使用的是旧的 Anki 版本,你的 Anki 文件将位于 Documents/Anki
文件夹中。
On Mac computers, recent Anki versions store all their files in the
~/Library/Application Support/Anki2
folder. The Library folder is hidden by default, but can be revealed in Finder by holding down the option key while clicking on the Go menu. If you're on an older Anki version, your Anki files will be in yourDocuments/Anki
folder.
Linux 上,较新的 Anki 版本将你的数据存储在 ~/.local/share/Anki2
中,如果你设置了自定义数据路径,则存储在 $XDG_data_HOME/Anki2
。旧版本的 Anki 将你的文件存储在 ~/Documents/Anki
或 ~/Anki
中。
On Linux, recent Anki versions store your data in
~/.local/share/Anki2
, or$XDG_DATA_HOME/Anki2
if you have set a custom data path. Older versions of Anki stored your files in~/Documents/Anki
or~/Anki
.
在 Anki 文件夹中,程序级别和账户级别的首选项存储在一个名为 prefs.db 的文件中。
Within the Anki folder, the program-level and profile-level preferences are stored in a file called prefs.db.
每个账户也有一个单独的文件夹。文件夹包含:
There is also a separate folder for each profile. The folder contains:
- 你的笔记、牌组、卡片等放在一个名为 collection.anki2 的文件夹中
Your notes, decks, cards and so on in a file called collection.anki2
- 音频和图片放在 一个名为 collection.media 的文件夹中
Your audio and images in a collection.media folder
- 备份文件夹
A backups folder
- 一些系统文件
Some system files
当 Anki 打开时,你不应该复制或移动你的集合。这样做可能会导致你的集合损坏。请不要移动或修改文件夹中的其他文件。
You should never copy or move your collection while Anki is open. Doing so could cause your collection to become corrupt. Please do not move or modify the other files in the folder either.
启动选项
Startup Options
如果你在一台计算机上进行了破坏性更改,而在另一台计算机中有一个未损坏的副本,你可能希望在不同步的情况下启动 Anki,以便在不首先下载更改的情况下使用完全同步选项。同样,如果你在使用 Anki 时遇到问题,你可能希望(或可能被指示)暂时禁用插件,以查看是否是某个插件导致了问题。在启动 Anki 的同时按住 Shift
键可以同时完成这两件事。
If you have made a destructive change on one computer and have an undamaged copy on another computer, you may wish to start Anki without syncing in order to use the full sync option without first downloading the changes. Similarly, if you are experiencing problems with Anki, you might want to (or might be instructed to) disable add-ons temporarily to see if one might be causing the problem. You can do both of these things by holding down the
Shift
key while starting Anki.
可以在启动期间指定自定义文件夹位置。这是一项高级功能,主要用于便携式安装,我们建议你在大多数情况下使用默认位置。
It is possible to specify a custom folder location during startup. This is an advanced feature that is primarily intended to be used with portable installations, and we recommend you use the default location in most circumstances.
指定备用文件夹的语法如下:
The syntax to specify an alternate folder is as follows:
anki -b /path/to/anki/folder
- 如果你有多个账户,你可以传递
-p <name>
来加载特定的账户。If you have multiple profiles, you can pass
-p <name>
to load a specific profile. - 如果你传递 -p 一些错误名称,Anki 将在启动时显示账户界面。如果账户不存在,则加载最后使用的账户内容。
If you pass -p some-fake-name, Anki will show the profile screen on startup. If no profile is provided, the last-used profile is loaded.
- 要更改接口语言,请使用
-l <iso 639-1 language code>
,例如日语的-l ja
。To change the interface language, use -l <iso 639-1 language code>, such as "-l ja" for Japanese.
如果你总是想使用自定义文件夹位置,可以修改 Anki 的快捷方式。在 Windows 中,右键单击快捷方式,选择“属性”,选择“快捷方式”选项卡,然后在程序的路径后添加“-b \path\to\data\folder”,如下示例:
If you always want to use a custom folder location, you can modify your shortcut to Anki. On Windows, right-click on the shortcut, choose Properties, select the Shortcut tab, and add "-b \path\to\data\folder" after the path to the program, which should leave you with something like
"C:\Program Files\Anki\anki.exe" -b "C:\AnkiDataFolder"
你还可以将此技术与 -l 选项一起使用,以便在不同的语言中轻松使用 Anki。
You can also use this technique with the -l option to easily use Anki in different languages.
在 Windows 上,应该使用反斜杠 \
,而不是正斜杠 /
。
On Windows, you should use a backslash
\
not a forward slash/
.
在 Mac 上,单击 Anki 图标时没有简单的方法可以改变行为,但可以从终端使用自定义文件夹启动 Anki:
On a Mac there is no easy way to alter the behaviour when clicking on the Anki icon, but it is possible to start Anki with a custom base folder from a terminal:
open /Applications/Anki.app --args -b ~/myankifolder
或者,你可以定义环境变量“ANKI_BASE”。在 Windows 上,可以使用以下内容定义环境变量:
Alternatively, you can define the environment variable "ANKI_BASE". On Windows, you can define the environment variable with:
set "ANKI_BASE=C:/path/to/AnkiDataFolder"
在 Linux 和 macOS 上,你可以使用:
On Linux and macOS, you can use:
export ANKI_BASE="/path/to/AnkiDataFolder"
DropBox 和文件同步
DropBox and File Syncing
我们不建议你直接与第三方同步服务同步你的 Anki 文件夹,因为在使用时同步文件可能会导致数据库损坏。
We do not recommend you sync your Anki folder directly with a third-party synchronization service, as it can lead to database corruption when files are synced while in use.
如果你只想同步你的媒体文件 ß,你可以将外部文件夹链接到 DropBox 等服务中。有关更多信息,请参阅 在 Dropbox 外同步文件夹。
If you just want to synchronize your media, you can link external folders into services like DropBox. Please see DropboxWiki: Sync Folders Outside Dropbox (archive.org) for more info.
如果你也希望保持集合同步,强烈建议你创建一个脚本,将文件从同步文件夹复制到本地文件夹,启动 Anki,然后在关闭 Anki 时将文件复制回。这将确保文件在打开时永远不会同步。
If you wish to keep your collection in sync as well, it is strongly recommended that you create a script that copies your files from your synced folder to a local folder, launches Anki, and then copies the files back when Anki is closed. This will ensure that the files are never synchronized while they are open.
网络文件系统
Network Filesystems
我们强烈建议你让 Anki 将文件存储在本地硬盘上,因为网络文件系统可能会导致数据库损坏。如果网络文件系统是你唯一的选择,建议定期使用“工具”>“检查数据库”来检测损坏。
We strongly recommend you have Anki store your files on a local hard disk, as network filesystems can lead to database corruption. If a network filesystem is your only option, regular use of Tools>Check Database to detect corruption is recommended.
从闪存驱动器运行
Running from a Flash Drive
在 Windows 上,Anki 可以安装在 USB/闪存驱动器上,并作为便携式应用程序运行。以下示例假设你的 USB 驱动器是驱动器 G。
On Windows, Anki can be installed on a USB / flash drive and run as a portable application. The following example assumes your USB drive is drive G.
- 将
\Program Files\Anki
文件夹复制到闪存驱动器,这样就有了G:\Anki
这样的文件夹。Copy the \Program Files\Anki folder to the flash drive, so you have a folder like G:\Anki.
- 创建一个名为
G:\anki.bat
的文本文件,其中包含以下文本:Create a text file called G:\anki.bat with the following text:
g:\anki\anki.exe -b g:\ankidata
如果希望阻止黑色命令提示符窗口保持打开状态,则可以使用:
If you would like to prevent the black command prompt window from remaining open, you can instead use:
start /b g:\anki\anki.exe -b g:\ankidata
- 双击 anki.bat 应使用存储在 G:\ankidata 中的用户数据启动 anki。
Double-clicking on anki.bat should start Anki with the user data stored in G:\ankidata.
包含驱动器号的完整路径是必需的-如果你尝试使用 \anki\anki.exe
,你会发现同步停止工作。
The full path including drive letter is required - if you try using
\anki\anki.exe
instead you will find syncing stops working.
如果你的闪存驱动器格式化为 FAT32,则与 AnkiWeb 的媒体同步可能无法工作。请将驱动器格式化为 NTFS,以确保媒体正确同步。
Media syncing with AnkiWeb may not work if your flash drive is formatted as FAT32. Please format the drive as NTFS to ensure media syncs correctly.
备份
Backups
请查看备份
Please see this section.
无法访问的硬盘
Inaccessible Harddisk
如果 Anki 无法写入 Anki 文件夹中的文件,则在启动时会显示一条消息,说明 Anki 无法向硬盘写入,并且 Anki 将关闭。如果你不确定如何修复权限,请联系你附近熟悉计算机并能帮助你的人。
If Anki can't write to files in the Anki folder, a message will be displayed on startup saying that Anki can't write to the harddisk, and Anki will close. If you're unsure how to fix the permissions, please contact someone near you who is knowledgeable about computers and can help you out.
临时文件夹的权限
Permissions of Temp Folder
Anki 使用系统的临时文件夹来存储临时数据。如果此文件夹的权限被流氓应用程序或有缺陷的防病毒应用程序从默认设置更改,Anki 将无法正常工作。
Anki uses the system's temporary folder to store temporary data. If the permissions of this folder have been changed from the default settings by a rogue app or buggy antivirus app, Anki will not function properly.
如果你使用的是 Windows 7 计算机,下面列出了解决问题的一般步骤。由于这有点复杂,如果你不确定,请询问了解 Windows 的人。
If you're on a Windows 7 machine, the general steps to fix the problem are listed below. As this is somewhat complicated, please ask someone knowledgeable about Windows if you are not sure.
- Click on the start bar, and type in %temp% (including the percents), then hit
Enter
. - Go up one folder, and locate the temp folder. Right click on it, and choose Properties.
- In the security tab, click on Advanced.
- Click on the Owner tab. If you're not listed as the owner, click the button to take ownership.
- On the permissions tab, ensure that you have full control. On a default W7 install the control will actually be inherited from c:\users\your-username.
Corrupt Collections
Anki 使用的文件格式可以防止程序和计算机崩溃,但如果文件在 Anki 打开时被修改、存储在网络驱动器上或被错误损坏,则你的集合仍有可能损坏。
Anki uses a file format that is robust against program and computer crashes, but it's still possible for your collection to become corrupt if the files are modified while Anki is open, stored on a network drive, or corrupted by a bug.
当你运行“工具”>“检查数据库”时,如果 Anki 检测到文件已损坏,你将收到一条消息。从中恢复的最佳方法是从最近的自动备份中恢复,但如果备份太旧,则可以尝试修复损坏。
When you run Tools>Check Database, you will receive a message if Anki detects the file has been corrupted. The best way to recover from this is to restore from the most recent automatic backup, but if your backup is too old, then you can attempt to repair the corruption instead.
在 Linux 上,请确保已安装 sqlite3。在 Mac 上,它应该已经安装好了。在 Windows 上,下载http://www.sqlite.org/sqlite-3_6_23.zip.
On Linux, make sure sqlite3 is installed. On a Mac, it should be installed already. On Windows, download http://www.sqlite.org/sqlite-3_6_23.zip.
接下来,创建 collection.anki2 文件的备份,以防以下步骤出现问题。
Next, create a backup of your collection.anki2 file, in case something goes wrong with the steps below.
Linux/macOS
打开终端,更改到集合所在的文件夹,然后键入:
Open a terminal, change to the folder your collection is located in, and type:
sqlite3 collection.anki2 .dump > dump.txt
在文本编辑器中打开生成的 dump.txt 文件,然后查看最后一行。如果它显示“rollback;”,则将其更改为“commit;”
Open the resulting dump.txt file in a text editor, and look at the final line. If it reads "rollback;", change it to "commit;"
然后在终端中运行以下操作:
Then run the following in a terminal:
cat dump.txt | sqlite3 temp.file
请确保使用 temp.file-不要将 collection.anki2 放在右侧,否则将清空文件。完成后,继续执行最后一步。
Make sure you use temp.file - do not put collection.anki2 on the right, or you will blank out the file. When you're done, proceed to the final step.
Windows
将sqlite3.exe
程序和你的牌组复制到桌面上。然后转到“开始”>“运行”并键入cmd.exe
。
Copy the
sqlite3.exe
program and your deck to your desktop. Then go to Start>Run and type incmd.exe
.
如果你使用的是最新的 Windows,则命令提示符可能不会在桌面上启动。如果在命令提示符中没有显示在桌面,请键入以下内容,将“administrator”替换为登录名。
If you're on a recent Windows, the command prompt may not start on your desktop. If you don't see desktop displayed in the command prompt, type something like the following, replacing 'administrator' with your login name.
cd C:\Users\Administrator\Desktop
然后输入:
Then type:
sqlite3 collection.anki2 .dump > dump.txt
在文本编辑器中打开生成的 dump.txt 文件,然后查看最后一行。如果它显示“rollback;”,则将其更改为“commit;”
Open the resulting dump.txt file in a text editor, and look at the final line. If it reads "rollback;", change it to "commit;"
然后在终端中运行以下操作:
Then run the following in a terminal:
type dump.txt | sqlite3 temp.file
请确保使用 temp.file-不要将 collection.anki2 放在右侧,否则将清空文件。完成后,继续执行最后一步。
Make sure you use temp.file - do not put collection.anki2 on the right, or you will blank out the file. When you're done, proceed to the final step.
最后一步
Final Step
请检查你是否没有收到错误消息,以及 temp.file 是否为空。该过程在此过程中优化了集合,因此新文件比旧文件小一些是正常的。
Check that you didn't get an error message, and that temp.file is not empty. The procedure optimizes the collection in the process, so it's normal for the new file to be somewhat smaller than the old one.
当你确认文件不为空时:
When you've confirmed the file is not empty:
- 将原始 collection.anki2 文件重命名为其他文件
rename the original collection.anki2 file to something else
- 将 temp.file 重命名为 collection.anki2
rename temp.file to collection.anki2
- 将 collection.anki2 移回集合文件夹,覆盖旧版本
move collection.anki2 back into your collection folder, overwriting the old version
- 启动 Anki,然后转到“工具”>“检查数据库”以确保集合已成功还原。
start Anki and go to Tools>Check Database to make sure the collection has been successfully restored.