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-06-30 16:33
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » Differential backup of files View 1,490 Replies 8
Original Poster Posted 2006-08-17 08:40 ·  中国 四川 德阳 什邡市 电信
新手上路
Credits 14
Posts 5
Joined 2006-08-16 11:52
19-year member
UID 60628
Status Offline
I want to back up the newly added files in a folder. That is, first compare which files in the target folder have not been backed up, and then back up the new files. How should this code be written呀:lol::lol:
Floor 2 Posted 2006-08-17 11:59 ·  中国 四川 德阳 什邡市 电信
新手上路
Credits 14
Posts 5
Joined 2006-08-16 11:52
19-year member
UID 60628
Status Offline
Is there any big brother who knows how to do it?
Floor 3 Posted 2006-08-17 14:29 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
The description is not specific enough to write specific code. Such posts should be transferred to the Batch Processing Room.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 4 Posted 2006-08-17 15:08 ·  中国 四川 德阳 什邡市 电信
新手上路
Credits 14
Posts 5
Joined 2006-08-16 11:52
19-year member
UID 60628
Status Offline
In folder A, there are: 1.TXT, 2.TXT, 3.TXT. In folder B, there are: 1.TXT, 2.TXT. I want to compare the files in folders A and B, and copy the newly added 3.TXT to folder B.
Floor 5 Posted 2006-08-17 17:24 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
```
@echo off
cd /d "Folder A"
for %%i in (*.txt) do (
if not exist "Folder B\%%i" copy "%%i" "Folder B">nul 2>nul
)
explorer "Folder A"
explorer "Folder B"
```

[ Last edited by namejm on 2006-8-18 at 14:41 ]
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 6 Posted 2006-08-18 14:36 ·  中国 四川 德阳 什邡市 电信
新手上路
Credits 14
Posts 5
Joined 2006-08-16 11:52
19-year member
UID 60628
Status Offline
Floor 7 Posted 2006-08-18 14:56 ·  中国 四川 德阳 什邡市 电信
新手上路
Credits 14
Posts 5
Joined 2006-08-16 11:52
19-year member
UID 60628
Status Offline
If the folder A is to be changed to a network path, it is \\192.168.1.1\F$\文件夹A
Floor 8 Posted 2006-08-18 16:07 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
I don't know much about network commands, and I don't have the conditions to test them. Still, please ask the experts to take action.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 9 Posted 2006-09-07 05:54 ·  中国 福建 三明 电信
中级用户
★★
Credits 316
Posts 83
Joined 2005-03-01 00:00
21-year member
UID 36626
Gender Male
Status Offline
xcopy \\192.168.1.1\F$\文件夹A L:\ /s /d /y /c >new_copy.log

/S Copies directories and subdirectories, excluding empty ones.

/D:m-d-y Copies files changed on or after the specified date. If no date is given, copies only files where the source time is newer than the destination time.

/Y Suppresses prompting to confirm overwriting an existing destination file.

/C Continues copying even if there are errors.

new_copy.log will record the files you copy each time
Forum Jump: