Batch (xcopy all files to folder) with loop
can anyone help me with loop in batch for windows? i want make script that will allow me to do something like this:
1. copy all folders and files fro开发者_高级运维m Drive I: to X:\folder0001;
2. when done display: "Done"; (i ejected cd)
3. "enter" to next copy;
1. copy all folders and files from Drive I: to X:\folder0002;
2. when done display: "Done"; (i ejected cd)
3. "enter" to next copy;
...
1. copy all folders and files from Drive I: to X:\folder0010;
2. when done display: "Done"; (i ejected cd)
3. "enter" to next copy;
button q = exit
copy i do with changing manually number with command:
for %%f in (i:) do xcopy %%f X:\folder001\ /e,
i want only press enter and change cd
but i dont know how to create this script :(
Try the following:
@echo off
setlocal enabledelayedexpansion
set number=1
FOR /L %%C IN (1,1,100) DO (
set dest=!number!
for %%N in (9999 999 99 9) do if !number! LEQ %%N set dest=0!dest!
xcopy I\*.*I:\folder!dest!" /E /I
ECHO *** CHANGE CD OR CTRL-C TO QUIT****
PAUSE
set /a number+=1
)
I don't think there's a way to check input from the keyboard.
Not all the help here but at least some :)
@echo off
if %1. == . GOTO NOPARM
if %2. == . GOTO NOPARM
FOR /F "tokens=*" %%G IN ('DIR /B /AD %1*') XCOPY %%G %2 /e
GOTO END
:NOPARM
echo missing folder name
:END
the message is missing... don't know how to pause it on every iteration :(
精彩评论