DOS batch file copies "Anki2" folder to specified location

The following DOS batch file copies the contents of your “Anki2” in C: to any folder of your choice. Within that folder, each run creates a new folder with today’s date, such as: “2022_03_24”

sd = source directory
dd = destination directory

As usual for backups, CLOSE Anki first. Maybe a pro can add a line to close Anki. But it needs to be an orderly procedure, you can’t simply kill the process - as in Task Manager.

If you run the prog twice on the same day, I suppose it will simply overwrite whatever was previously there, so there might not be any harm done. It’s up to you.

I only understand the first few lines of the prog. If anyone wants to provide a translation - please do.

Remember to edit your Username in third line: Set “sd…”


REM This bat copies files from sd to dd
@Echo Off
Set "sd=C:\Users\<me>\AppData\Roaming\Anki2
Set "dd=E:\Documents\Data\1SoftwareRelated\Backups\Anki2"
Set "ds="
If Not Exist "%sd%\" Exit /B
For /F "Tokens=1-3Delims=/ " %%A In ('RoboCopy/NJH /L "\|" Null'
) Do If Not Defined ds Set "ds=%%A_%%B_%%C"
If Not Defined ds Exit /B
RoboCopy "%sd%" "%dd%\%ds%" /E


Can be replaced by:

Set "sd=%USERPROFILE%\AppData\Roaming\Anki2

What is your use for this? Isn’t it simpler to use Anki’s native export feature? That only copies the files you actually need to restore your collection, and creates a single file.



The main reason was to keep backups in separate folders. The name of the folder is a date, such as “2022_03_25”.