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-20 04:35
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Copy a file to many folders (with a pattern) View 4,480 Replies 21
Original Poster Posted 2007-01-04 00:52 ·  中国 广东 深圳 宝安区 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
Copy the bak folder to folders such as a001, a002, ……, a009, ……, a010, ……, a100
Floor 2 Posted 2007-01-04 00:52 ·  中国 广东 深圳 宝安区 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
Seek the advice of all experts
Floor 3 Posted 2007-01-04 00:57 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
```
@echo off
for /l %%i in (1,1,100) do call :copy_ %%i
goto :eof

:copy_
set num=00%1
set name=a%num:~-3%
copy bak %name%
goto :eof
```
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 4 Posted 2007-01-04 04:08 ·  中国 广东 肇庆 电信
初级用户
★★
Credits 152
Posts 74
Joined 2005-12-01 23:06
20-year member
UID 46314
Status Offline
There is a problem with the line "copy bak %name%" in the batch file upstairs. If there are no such folders in this directory originally, it will go wrong!
Floor 5 Posted 2007-01-04 04:16 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
The owner of the post did not specifically state whether these folders exist. According to the general understanding, they are default to exist; if they do not exist, then it can only be blamed on the owner of the post for not making it clear; for ambiguous questions, no one, no matter who, can solve them perfectly.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 6 Posted 2007-01-04 23:56 ·  中国 广东 深圳 宝安区 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
I'm sorry, I'm a newbie. I want to save some trouble in actual application, so I come to ask the experts.

I didn't think too much about my question, sorry
Floor 7 Posted 2007-01-05 00:09 ·  中国 广东 深圳 宝安区 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
```batch
@echo off
for /l %%i in (1,1,100) do call :copy_ %%i
goto :eof

:copy_
set num=00%1
set name=a%num:~-3%
xcopy bak "%name%" /e /i
goto :eof
```

我试过了,可是目标都成了文件,而不是文件夹

我的目的是把BAK这个文件夹拷贝到已经存在的文件夹中(a001,a002 ……a100这些目录是已经存在的文件夹)
Floor 8 Posted 2007-01-05 01:49 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Hehe, didn't read the question carefully, thought bak was a file, made a mistake. To copy a folder, you should replace copy with xcopy and add appropriate parameters.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 9 Posted 2007-01-05 04:35 ·  中国 广东 深圳 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
Copy the "Documents and Settings" file to the folders A001, A002, A003...A110 folders

[ Last edited by beyoungse on 2007-1-7 at 12:33 PM ]
Floor 10 Posted 2007-01-07 12:35 ·  中国 广东 深圳 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
Copy the "Documents and Settings" file to the folders A001, A002, A003……A110Folder
Floor 11 Posted 2007-01-07 12:48 ·  中国 广东 广州 天河区 电信
高级用户
★★★
潜水修练批处理
Credits 788
Posts 366
Joined 2006-12-31 02:43
19-year member
UID 75048
Gender Male
Status Offline
The NTUSER and NTUSER.DAT files in the Documents and Settings\%username%\ folder are registry - related files, and they cannot be normally copied.
Floor 12 Posted 2007-01-07 12:55 ·  中国 广东 深圳 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
This folder was created by myself, and it only contains a few files created by myself. Boss, help me.
Floor 13 Posted 2007-01-07 12:56 ·  中国 广东 深圳 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
My purpose is to place the user's desktop on a file server, and the user's system is read-only
Floor 14 Posted 2007-01-07 13:02 ·  中国 广东 广州 天河区 电信
高级用户
★★★
潜水修练批处理
Credits 788
Posts 366
Joined 2006-12-31 02:43
19-year member
UID 75048
Gender Male
Status Offline
Just enclose the path with "" when copying, and it can be copied normally
Floor 15 Posted 2007-01-07 13:10 ·  中国 广东 深圳 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
Can you help write it? Operating in the current directory, no need to write the path, right?

I used the above batch processing,
@echo off
for /l %%i in (1,1,100) do call :copy_ %%i
goto :eof

:copy_
set num=00%1
set name=a%num:~-3%
copy Documents and Settings %name%
goto :eof
Forum Jump: