Here is the code.
xcopy /c/s/z "%appdata%" "./backup"
Is there a way to make it not copy folders with nothing in them?
By specifying the /s switch, the xcopy statement will ignore empty directories and subdirectories by default.