![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-02 05:59 |
48,037 topics / 350,122 posts / today 2 new / 48,250 members |
| DOS批处理 & 脚本技术(批处理室) » How to batch copy specified files under a folder?? |
| Printable Version 2,012 / 9 |
| Floor1 newstart | Posted 2006-10-08 23:47 |
| 新手上路 Posts 4 Credits 12 | |
|
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 ] |
|
| Floor2 namejm | Posted 2006-10-08 23:53 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
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? |
|
| Floor3 newstart | Posted 2006-10-09 00:14 |
| 新手上路 Posts 4 Credits 12 | |
|
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, |
|
| Floor4 weilong888 | Posted 2006-10-09 00:32 |
| 银牌会员 Posts 548 Credits 1,270 | |
|
Enter "help xcopy" in CMD first
|
|
| Floor5 namejm | Posted 2006-10-09 00:35 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
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. |
|
| Floor6 jieok3375 | Posted 2006-10-09 00:36 |
| 中级用户 Posts 130 Credits 282 From 广东 | |
|
The LZ's question doesn't seem to be very clear... (My comprehension ability is poor)
|
|
| Floor7 newstart | Posted 2006-10-09 05:48 |
| 新手上路 Posts 4 Credits 12 | |
|
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 |
|
| Floor8 namejm | Posted 2006-10-09 11:43 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
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: |
|
| Floor9 lxmxn | Posted 2006-10-09 12:26 |
| 版主 Posts 4,938 Credits 11,386 | |
|
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~~ |
|
| Floor10 newstart | Posted 2006-10-09 20:17 |
| 新手上路 Posts 4 Credits 12 | |
|
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 ] |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |