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-29 07:58
中国DOS联盟论坛 » 论坛回收站 » Where is there a mistake? View 8,779 Replies 2
Original Poster Posted 2011-01-10 01:10 ·  中国 福建 南平 电信
新手上路
Credits 12
Posts 5
Joined 2011-01-04 11:43
15-year member
UID 180303
Gender Male
Status Offline
The correct code should be:

for %%i in (c d e f ) do (for /r "%%i" %%j in (*.txt) do copy "%%j" E:\1 \y >nul)

The original code had a syntax error in the "for /r" part. The "for /r" should specify the root directory properly with the correct syntax.
Floor 2 Posted 2011-01-10 03:42 ·  中国 上海 电信
新手上路
Credits 15
Posts 8
Joined 2008-09-21 13:11
17-year member
UID 126206
Gender Male
Status Offline
@echo off
for %%i in (c d e f ) do (
for /f "delims=" %%j in ('dir /a-d /s /b "%%i:\*.txt"') do (
xcopy /y "%%j" e:\1
))>nul

[ Last edited by andyrave on 2011-1-10 at 03:45 ]
Floor 3 Posted 2011-01-10 07:59 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
for %%i in (c d e f ) do (for /r %%i %%j in (*.txt) do copy "%%j" E:\1 \y >nul)
for %%a in (set) do clause
1, Among all forms of for: In the extended parameter part, outside (set) and the clause, %%a, delayed variable!a!, etc. are not allowed, but %1 or directly extended variable %a% can be used
2, This path generally needs to be enclosed in quotes

[ Last edited by Hanyeguxing on 2011-1-10 at 09:37 ]
Forum Jump: