|
newstart
新手上路

积分 12
发帖 4
注册 2006-10-8
状态 离线
|
『楼 主』:
如何批量复制文件下的指定文件??
使用 LLM 解释/回答一下
以前有过人问过这个问题。不过贴子上的东西没看太懂。
原贴( http://www.cn-dos.net/forum/viewthread.php?tid=20648)
我想问一下。
比如,我C盘下A文件夹里有10000个.txt文档,
文件名是a00001-a09999(都是.txt文档,不是文件夹)
而我有一个目录。约1000个,是我需要A里的文件,
比如他们是
C:\a\a00001.txt
C:\a\a00602.txt
C:\a\a00203.txt
C:\a\a00007.txt
。。。
C:\a\a04203.txt
C:\a\a04303.txt
等无规则的名字。
我想请问一下,如何把C:\a里面(再注,A里无子文件夹)
我想目录里的文档复制到别的文件夹下比如C:\b ?
我在网上搜索的结果是在DOS下运行如XCOPY的东西。但说的不太清楚。
请问有什么方法么?如果有请说的清楚,详细一些,谢谢。
或者发邮件到 to7m8@126.com. thx!
Last edited by newstart on 2006-10-9 at 05:50 ]
There was someone who asked this question before. But I didn't understand the content in the post very well.
Original post ( http://www.cn-dos.net/forum/viewthread.php?tid=20648)
I want to ask.
For example, there are 10,000.txt documents in folder A under drive C.
The file names are a00001 - a09999 (all are.txt documents, not folders)
And I have a directory. About 1,000 of them are the files I need from A.
For example, they are
C:\a\a00001.txt
C:\a\a00602.txt
C:\a\a00203.txt
C:\a\a00007.txt
...
C:\a\a04203.txt
C:\a\a04303.txt
etc. with irregular names.
I want to ask, how to copy the documents in C:\a (note again, there are no subfolders in A)
I want to copy the documents in the directory to another folder such as C:\b?
The result of my search on the Internet is to run something like XCOPY under DOS. But it's not very clear.
May I ask what methods are there? If there are, please explain clearly and in detail, thank you.
Or send an email to to7m8@126.com. thx!
Last edited by newstart on 2006-10-9 at 05:50 ]
|
|
2006-10-8 23:47 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
请说明你的DOS版本,比如是纯DOS还是windows下的CMD,若是纯DOS,那又是哪个版本。
另外,你说的是文件还是文件夹?a00001-a09999怎么看都像文件夹名啊。“他们的是a00003..a004234..a032043...等无规则的名字。",这样说来,这些文件的名和A下的文件名还是一样的么?
Please specify your DOS version, such as whether it is pure DOS or CMD under Windows. If it is pure DOS, then which version is it.
Also, are you talking about files or folders? a00001-a09999 looks like a folder name at first glance. "Their names are a00003..a004234..a032043... and other irregular names." In this case, are the names of these files still the same as the file names under A?
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-10-8 23:53 |
|
|
newstart
新手上路

积分 12
发帖 4
注册 2006-10-8
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
1.DOS是xp下的cmd
2.a00001-a09999都是.txt的文档
3.而我需要的目录是是a00003..a004234..a032043...等无规则的名字,(都是文档名字)
4,我需要的是把目录中的1000个文档复制到另外的文件夹,如果根据目录找的话会相当的复杂。所以,特来请教!~!谢谢,
1. DOS is the cmd under xp
2. a00001 - a09999 are all.txt documents
3. And the directory I need is a00003..a004234..a032043... and other irregular names, (all are document names)
4. I need to copy 1000 documents in the directory to another folder. If I find them according to the directory, it will be quite complicated. So I come to ask for advice!~! Thank you,
|
|
2006-10-9 00:14 |
|
|
weilong888
银牌会员
    
积分 1270
发帖 548
注册 2004-5-31
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
在CMD中先输入help xcopy
Enter "help xcopy" in CMD first
|
|
2006-10-9 00:32 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
Climbing大侠的代码写得已经够强悍了,如果换成我,我也会弄个类似的代码给你的,而你说看不太懂,那就没办法了。
给你提示一下:要用到for语句的扩展用法,提取文件名,用for %%i in () do echo %%~ni 的格式。
回过头来再看一下的描述,发现你是这样说的 “而我需要的目录是是a00003..a004234..a032043...等无规则的名字,(都是文档名字)”,a00003等究竟是文件还是文件夹,我又被你搞糊涂了,汗一个。
The code written by Master Climbing is already powerful enough. If it were me, I would also come up with a similar code for you. And you said you don't quite understand it, then there's no way.
Let me give you a hint: You need to use the extended usage of the for statement, extract the file name, in the format of for %%i in () do echo %%~ni.
Looking back at your description, you said "And the directory I need is names like a00003..a004234..a032043... which are irregular, (all are document names)". Whether a00003, etc. are files or folders confuses me again, sweat.
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-10-9 00:35 |
|
|
jieok3375
中级用户
  
积分 282
发帖 130
注册 2006-9-20 来自 广东
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
楼主的问题讲的好像不太明白……
(偶滴理解能力差)
The LZ's question doesn't seem to be very clear... (My comprehension ability is poor)
|

~~~~好好学习
天天向上~~~~ |
|
2006-10-9 00:36 |
|
|
newstart
新手上路

积分 12
发帖 4
注册 2006-10-8
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
namejm版主,我所说的目录就是存放文档(.txt)的地址的。
例如:
C:\a\a00001.txt
C:\a\a00002.txt
C:\a\a00003.txt
C:\a\a00007.txt
C:\a\a04303.txt
..
...
很不幸,我的表达能力不够专业,让大家见笑了。
我C盘下A文件夹里有10000个.txt文档,
文件名是a00001.txt-a09999.txt(都是.txt文档,不是文件夹)
而我有一个目录。约1000个,是我需要A里的文件,
比如他们是
C:\a\a00001.txt
C:\a\a00602.txt
C:\a\a00203.txt
C:\a\a00007.txt
。。。
C:\a\a04203.txt
C:\a\a04303.txt
等无规则的名字。
我想请问一下,如何把C:\a里面(再注,A里无子文件夹)
我想目录里的文档复制到别的文件夹下比如C:\b ?
以下是我用Climbing大大写的来试,
结果提示我说"此时不应有 %%i
@echo off
::C:\b
set dst=C:\a
for /F "tokens=*" %%i in (list.txt) do md %dst%%%~pi && copy /y %%i %dst%%%~pi && echo success copy %%i
我想问一下。1,以上语句是一块粘贴到cmd的c:\右边回车就行了么?
2,list.txt放在c:\下面就行了么?
3,形如a00234的是.txt文档,不是文件夹!
Last edited by newstart on 2006-10-9 at 05:54 ]
Moderator namejm, the directory I mentioned is the address where the documents (.txt) are stored.
For example:
C:\a\a00001.txt
C:\a\a00002.txt
C:\a\a00003.txt
C:\a\a00007.txt
C:\a\a04303.txt
..
...
Unfortunately, my expression ability is not professional, which makes everyone laugh.
I have 10,000 .txt documents in folder A under drive C,
The file names are a00001.txt - a09999.txt (all are .txt documents, not folders)
And I have a directory. There are about 1,000, which are the files I need in A,
For example, they are
C:\a\a00001.txt
C:\a\a00602.txt
C:\a\a00203.txt
C:\a\a00007.txt
...
C:\a\a04203.txt
C:\a\a04303.txt
and other irregular names.
I want to ask, how to copy the documents in C:\a (note again, there are no subfolders in A)
I want to copy the documents in the directory to another folder, such as C:\b?
The following is what I tried using the one written by Big Climbing,
The result prompted me that "There should not be %%i at this time
@echo off
::C:\b
set dst=C:\a
for /F "tokens=*" %%i in (list.txt) do md %dst%%%~pi && copy /y %%i %dst%%%~pi && echo success copy %%i
I want to ask. 1, Is the above statement pasted all at once and pressed Enter on the right of cmd c:?
2, Is list.txt placed under c:\?
3, The one in the form of a00234 is a .txt document, not a folder!
Last edited by newstart on 2006-10-9 at 05:54 ]
|
|
2006-10-9 05:48 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
楼主的问题已经属于CMD批处理的范围了,建议发往 DOS批处理 & 脚本技术(批处理室) 。
回答一下『第 7 楼』的部分问题:
1、climbing的代码不能在CMD命令窗口下运行,若要逐句运行的话,应该把所有的双百分号改成单百分号;
2、list.txt应该放在和这个批处理程序相同的目录下,或者放在任意目录下之后,把 (list.txt) 改成 (路径\list.txt) 的格式。
另外,我对你修改过后的描述还是有个关键的地方看不懂:"而我有一个 目录。约1000个,是我需要A里的文件",1000个目录?吓人哦。看了你后面的举例,应该是说1000条记录吧?姑且按照我的理解,把你的问题理解成:c:\a下有10000个文本文件,而你只想复制其中的1000个,这1000个文件的绝对路径已经被你提取出来了,放在一个叫list.txt的文本中,现在想把这1000个文本文件复制到c:\b下。针对这个具体需求,我写了一段代码,请你测试:
@echo off
:: list.txt里的内容为你即将复制的文档的绝对路径清单,一行一条记录
:: list.txt要和此脚本程序放在同一目录下
if not exist c:\b md c:\
for /f "tokens=*" %%i in (list.txt) do copy "%%i" c:\b
start c:\b
The problem of the original poster already belongs to the scope of CMD batch processing. It is suggested to post it to DOS Batch & Script Technology (Batch Processing Room).
Answer part of the questions in "Building 7":
1. The code of climbing cannot be run in the CMD command window. If you want to run it sentence by sentence, you should change all double percent signs to single percent signs;
2. list.txt should be placed in the same directory as this batch processing program, or after placing it in any directory, change (list.txt) to the format of (path\list.txt).
In addition, there is a key part of your modified description that I still don't understand: "And I have a directory. About 1000, which are the files I need in A". 1000 directories? That's scary. After looking at your subsequent examples, it should mean 1000 records? Let's姑且 according to my understanding, take your problem as: There are 10,000 text files under c:\a, and you only want to copy 1,000 of them. The absolute paths of these 1,000 files have been extracted by you and placed in a text called list.txt. Now you want to copy these 1,000 text files to c:\b. For this specific requirement, I wrote a piece of code, please test:
@echo off
:: The content in list.txt is the list of absolute paths of the documents you are about to copy, one record per line
:: list.txt should be in the same directory as this script program
if not exist c:\b md c:\
for /f "tokens=*" %%i in (list.txt) do copy "%%i" c:\b
start c:\b
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-10-9 11:43 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
楼主还是没有把问题描述清楚,把版主都搞急了~~
呵呵~~
建议提问的时候,尽量把问题描述详细一点~~
The original poster still didn't describe the problem clearly, which made the moderator anxious~~
Hehe~~
It is suggested that when asking a question, try to describe the problem in detail~~
|
|
2006-10-9 12:26 |
|
|
newstart
新手上路

积分 12
发帖 4
注册 2006-10-8
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
感谢namejm大大在8楼的回答。
你已经明白了我的意思*_^
我在cmd下。把你的程序改成一个%
结果。。。。。。。
。。。。。。。。。
。。。。。。。。哎。
终于成功了!!谢谢大家!:P:P:P
Last edited by newstart on 2006-10-9 at 20:23 ]
Thanks to user namejm for the answer on floor 8.
You have understood my meaning *_^
I'm in cmd. Changed your program to a %
Result............
...............
............... Hey.
Finally succeeded! Thank you all! :P:P:P
Last edited by newstart on 2006-10-9 at 20:23 ]
|
|
2006-10-9 20:17 |
|