中国DOS联盟论坛

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-09-23 14:10
47,812 topics / 349,917 posts / today 0 new / 48,273 members
DOS批处理 & 脚本技术(批处理室) » [Help] Batch script for finding files
Printable Version  1,986 / 6
Floor1 lin8197 Posted 2004-12-16 00:00
初级用户 Posts 36 Credits 186
Known: In n:\aaaa\ there are several files such as a.exe, b.exe, c.bat... where N = C:, D:, E:... M:

To find: The batch to copy the files in the aaaa folder to C:\.

This noob is not familiar with loop statements, so he has to search disk by disk, which is too troublesome. Please, great master, write a simple one.

Floor2 willsort Posted 2004-12-16 00:00
元老会员 Posts 1,512 Credits 4,432
Re lin8197:
A simplified program, ignoring many details and not tested, you try it first, if there are any problems, discuss them.
@echo off
if == %0 c d e f g h i j k l m
:loop
if == goto end
for %%f in (a.exe b.exe c.bat) do if exist %1:\aaaa\%%f copy %1:\aaaa\%%f c:\
shift
goto loop
:end

Floor3 lin8197 Posted 2004-12-16 00:00
初级用户 Posts 36 Credits 186
Thanks for the explanation. I tried it, it works under XP, but not under DOS and 98. I mainly use it under DOS, please help to modify it
Floor4 willsort Posted 2004-12-16 00:00
元老会员 Posts 1,512 Credits 4,432
Re lin8197: Please first tell me what the problem is (error message), then tell me your usage requirements (such as using on a specific model or a series of models). In short, it is important to describe it simply and accurately. The problems I think of may be file name problems (containing spaces), disk drive letter problems (may encounter an unready CD-ROM), is your problem one of these?
Floor5 lin8197 Posted 2004-12-16 00:00
初级用户 Posts 36 Credits 186
d:\>abc
0 file(s) copied
0 file(s) copied
0 file(s) copied

CDR101: Not ready reading drive GI tried it in the virtual machine, the above is the prompt
Floor6 lin8197 Posted 2004-12-16 00:00
初级用户 Posts 36 Credits 186
By the way, I didn't make it clear. I need to use it on different machines, and the number of partitions on each machine is different.
Floor7 willsort Posted 2004-12-17 00:00
元老会员 Posts 1,512 Credits 4,432
Re lin8197:
It seems that the first problem encountered is the judgment of non-hard disk drive letters. Because when 98 and DOS use if exist to access an unprepared drive, an error message will appear, while XP and 2000 ignore this error.
To solve it, first ensure that the drive letter list is as small as possible. I don't know how your c~m is determined. If possible, try to narrow its range as much as possible. In addition, a check should be made for whether each drive letter is ready. The simplest way is to use the third-party tool dready.com, which comes from the hosrt32 tool kit. The usage is as follows (the program has not been tested either). If your environment is not suitable for using the third-party tool, you can dynamically generate a script and then use debug to call the DOS interrupt to get a similar effect.
In addition, if used below DOS 6.xx, please pay attention to the 8.3 filename convention, otherwise some unexpected errors will occur.
@echo off
if == %0 $ c d e f g h i j k l m
:loop
shift
if == goto end
dready %1
if errorlevel 2 goto loop
for %%f in (a.exe b.exe c.bat) do if exist %1:\aaaa\%%f copy %1:\aaaa\%%f c:\
goto loop
:end
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023