China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-01 19:29
中国DOS联盟论坛 » 其它操作系统综合讨论区 » [Solved] About the problem of using robocopy to back up data View 5,807 Replies 0
Original Poster Posted 2019-05-02 12:05 ·  中国 江西 南昌 电信
中级用户
★★
Credits 220
Posts 99
Joined 2005-08-16 01:08
20-year member
UID 41691
Status Offline
Ask a question, in the WIN10 system, I want to use the robocopy command to back up two folders. The first Desktop can be backed up normally, and the second and third quoted "Saved Games" and "Burn\Burn" folders cannot be backed up. The command is as follows:
for %%a in (Desktop "Saved Games" "Burn\Burn") do if not exist D:\Users\%username%\%%a robocopy "%USERPROFILE%\%%a" "D:\Users\%username%\%%a" /e
The error content after the robocopy command is executed is as follows:
Source: C:\Users\Administrator"Saved Games"\
Destination: D:\Users\Administrator"Saved Games"\

Source: C:\Users\Administrator"Burn\Burn"\
Destination: D:\Users\Administrator"Burn\Burn"\

How to solve it, thank you!

Solved, the method is as follows:
Use %%~a, add quotes to the if judgment path "complete path"
for %%a in (Desktop "Saved Games" "Burn\Burn") do if not exist "D:\Users\%username%\%%~a" robocopy "%USERPROFILE%\%%~a" "D:\Users\%username%\%%~a" /e

[ Last edited by hbby on 2019-5-5 at 11:07 ]
Forum Jump: