Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a folder called Ram. In it there are, say, 10 folders. I want to copy these 10 folders to another folder Shyam. What I want to do through a batch file is not copy all of them at once. After I copy each file, I should be able to give the user a message and then the copying process should continue. How do I accomplish this?

I would insert the follwoing in your batch
echo MESSAGE GOES HERE
SLEEP n secondsWhere n is the number of seconds you it should display the message before continuing to copy the next file.
I guess you could also use PAUSE if you want the user to have to press a key to continue.
Or you could use
CHOICE /T:Y,n seconds MESSAGE HERE
The above would give the user the choice to press a key or it would automatically selet Yes after n seconds.
I hope this helps.

Hi,
Thanks for the response. Here is my code:
set totcount=0
set filecount=0
set targetdir=i:\shyam
FOR /f "tokens=*" %%G IN ('dir /b i:\ram') DO (call :s_do_sums "%%G")
echo Backing up files:%filecount% of %totcount%:backup
FOR /D %%G in (i:\ram) DO xcopy "%%G" "%targetdir%\" /e/y/decho Backing up files:%filecount% of %totcount%
pause:s_do_sums
start "Progress bar" /min
set /a totcount+=1
:end
--
The idea is to display a message to the user like: Backing 1 <<file>> of total <<files>> after each file has been copied. What happens in my code is that all the files are copied at once.
Choice, I suppose, does not work in WIN 2000. I am yet to try the sleep command. Can you make the changes in my code and reply back to me? I would appreicate such a gesture.
*

CHOICE was apparentl left out of 2000. SLEEP is not part of any WIN that I know of. You can use CHOICE from XP.
I think you neeed to use COPY, not xcopy. But before we get to that, what is:
"Progress bar" /min
=====================================
If at first you don't succeed, you're about average.M2

Hi,
The idea behind this code is to have a progress bar sort-of-thing as the batch file does the backup of user files wherein it plainly copies the files to another location.
I wanted to open another window which showed the status of the backup and that is the reason for that start command.
I feel that there is something wrong in the FOR loop which actually copies all the files at once instead of copying one file at a time which is what I want.
Choice is not available in XP. So also sleep. However, you can use the ping command to pause the system for a few moments. It could go something like this: @ping 127.1.0.1 -n 2 -w 10000 > nul
Can any of you please rectify the FOR clause for me so that only one file is copied at a time? I feel that this is possible with the xcopy comman itself.

XCOPY Source Destination /p
This will prompt before each new file is copied.
I only Batch if possible, 2000 more lines of code, oh well.

Thanks for the response. But my purpose is not to have any user response after each file is copied. It should be just a prompt that displays, say, for a couple of seconds or so, and automatically copies the second file. I feel that I should be using the do call option for the second loop but still nothing is working out the way I want. Any help would be appreciated.

@echo off
setLocal EnableDelayedExpansionfor /f "tokens=* delims= " %%a in ('dir/b/a-d') do (
set /a T+=1
set P=!P!*
echo copy %%a nul
cls
echo !P!
echo !T! copied so far
ping 1.1.1.1 -n 1 -w 1000 > nul
)
=====================================
If at first you don't succeed, you're about average.M2

Thanks for the response, Mechanix2Go. Your code is great but I still have a problem. Let me mention it to you in detail.
*
I want to use XCOPY to copy the files of the user. Your FOR loop (for /f "tokens=* delims= " %%a in ('dir/b/a-d'))gets me the names of all the files present in a particular drive. In my case it is I:\ So, I can use the XCOPY command immediately after the FOR loop in this fashion.
xcopy "i:\ram\"%%a "i:\shyam\" /e/d/y.
After the file gets copied from ram folder to shyam folder, I can use your other code for showing the progress bar of the backup.
However, I face a problem in xcopy.
Suppose there is a folder called test in folder ram. Inside the folder test there is a text file called raj. When I issue a XCOPY like XCOPY "i:\ram\test" "i:\shyam\" e/d/y what happens is that only the text file raj which is inside the folder test gets copied to the shyam folder. The test folder does not get copied at all! On the other hand, a command like this : xcopy "i:\ram" "i:\shyam\" works perfectly well. However, if I give such a command in the FOR loop then all the files will be copied at once that is not my purpose. I would like a message like the progress bar to be displayed after each file is copied which only the earlier command can do. However, there I face this problem. Can you tell me as to what is causing XCOPY to behave so strangely in the earlier instance?

Rajesh,
If I understand your problem right, you want to execute multiple commands under the for loop.
A minor introduction of ( ) in the for loop would do.
Try changing the for loop in your initial script to :
:backup
FOR /D %%G in (i:\ram) DO (
xcopy "%%G" "%targetdir%\" /e/y/decho Backing up files:%filecount% of %totcount%
pause
)
: .... and let me know whether it works.--
Holla.

Holla,
The problem persists.
Your code is absolutely correct and even what you have interpreted about my requirement is right. I do want to copy multiple files but with a little difference. Say, in folder ram there is one folder called test. Inside test folder there are three text files a, b and c. After xcopy copies the first file i.e. a I want to flash a message to the user. After file b has been copied again, I want to flash a message to the user. My initial command of xcopy "%%G" "%targetdir%\" /e/y/d works fine but it copies all the files at once, thereby leaving no scope for me to communicate with the user after each file is copied. Thus, as per the code given by Mechanix2Go, I modified the code like this: for /f "tokens=* delims= " %%G in ('dir i:\ram /b') do (xcopy "d:\ram\"%%G "i:\shyam\" /e/d/y). I also put the brackets which you recommended. What this code does is that it passes each file as a parameter (%%G) which the xcopy uses. Here the xcopy would copy each file, echo what I want to communicate to the user and then copy the next file and so on. However, despite putting the bracket, while all the files in ram folder are copied to shyam, the folders in ram folder are not copied. What's more, even if you try to copy individual files from the command prompt with xcopy, the same thing happens. For instance: xcopy "i:\ram\test" i:\shyam\" copies all the files under test folder to shyam but then the test folder is itself not copied to shyam.
Sorry for this long mail but I am just trying to make the problem clear.
*

There's no point in using xcopy to copy one file at a time. That's not what it was designed to do. So you're working against yourself.
You need to choose. If it's to be xcopy, forget the progress bar.
=====================================
If at first you don't succeed, you're about average.M2

Alright! So, are you telling me that copy is the solution here? If it is, then can you just modify my code and submit it here? I will be grateful if you do that. Also, is there any way wherein you can make the text which appears through echo bold or blink?

If you need to copy subdirectories, then xcopy is the right tool.
No idea how to make text bold etc.
=====================================
If at first you don't succeed, you're about average.M2

Rajesh,
Ok, let me understand your problem.
Am I right when I say "you want to copy files from one directory to another directory recursively and prompting the user after each file is copied?"
If that is the case, then this would work:
Careful: The xcopy parameters are set to overwrite
files at destination without asking.
@echo off
setlocal EnableDelayedExpansion
if %2a==a goto Usage
set curdir=%1
cd %1
for /r %%a in (*.*) do (
set fullflnm=%%a
set flnm=!fullflnm:%curdir%=!
echo f | xcopy /y/i/s !flnm:~1! "%2!flnm!"
pause
)
goto :EOF
:Usage
Echo Usage %0 Source-Directory Dest-Directory
Echo - Will copy files from Source-Directory to Dest-Directory recursively
echo - and prompt the user after each file is copied.
Echo - The directories supplied should not have any trailing slashes "\"
endlocal--
Holla.

Holla,
Thanks for your code. I will take some time to go through it and then get back to you with my queries. At first glance, I did not understand some commands for which I may need your help. In the meantime, can you tell me how to increment variables in batch files. For e.g. I created a variable like set a = 1 and then for incrementing it by 4, I used set /a !a!+=4 which did not work.
Again, thanks for your code. I will go through it and get back to you by Sunday.

Rajesh,
The command to increment variables in batch programming is the "set" command.
A very simple example of incrementing an environment variable in side a batch file is below. It prints from 1 to 10.
@echo off
set i=1
:start
echo i= %i%
set /a i = i + 1
if /i %i% leq 10 goto startThis will do for simple things.
You need to use EnabledDelayedExpansion if you have compound comparison statements and you want the variable to be interpreted at the execution time, rather than 'read' time(by the interpreter).--
Holla.

Holla,
Thanks a lot for your response. Regarding your earlier code for xcopy, kindly help me understand the meaning of the following code. I have somewhat learnt batch programming only in the past two weeks and therefore am not conversant with it's finer aspects.
What is 2a? Since you have not defined "a" what does IF 2a==a mean? Also, what does cd %1 mean? What does the ! mean in flnm=!fullflnm:%curdir%=! ?
Let me clarify that I want to manually pause the xcopy after each copy so that I can display a progress bar. Using the /P syntax in XCOPY does not provide me with this option.

Rajesh,
%1, %2, etc are the parameters passed into a batch file on the command line.if %2a==a goto Usage
- is a way of checking whether there are two parameters passed on the command line.
(If there is no second parameter, it would read "if a==a")
This batch file expects two parameters. If there is no second parameter on the command line, display usage. that is what it means."cd %1" means "Change directory to the first parameters passed on the command line to this batch file.
set flnm=!fullflnm:%curdir%=!- is a way of telling set command to get rid of the current directory prefix from each fully qualified filename.
Because the xcopy command options that I am using expects that form of copying: Xcopy source\dir\file.ext dest\dir\file.ext
Please note that the batch file given above
is an illustration on how what you asked can be achieved. I have tested it on restrictive test environment, that is simple directory structure with no spaces in it. And the batch file has to be invoked with fully qualified source and destination paths supplied to. It can be enlarged to handle spaces and relative paths, but then having found this itself difficult, I can only imagine how difficult that would be for you :-)--
Holla.

Rajesh,
A slightely improved batch file that takes care of spaces the path.
It should be invoked like -
Batchname "C:\source directory" "C:\destination directory"@echo off
setlocal EnableDelayedExpansion
if %2a==a goto Usage
cd %1
for /r %%a in (*) do (
set fullflnm=%%a
set flnm=!fullflnm:%cd%=!
echo f | xcopy /y/i/s "%%a" "%~2!flnm!"
pause
)
goto :EOF
:Usage
Echo Usage %0 Source-Directory Dest-Directory
Echo - Will copy files from Source-Directory to Dest-Directory recursively
echo - and prompt the user after each file is copied.
Echo - The directories supplied should be fully qualified with drive letter and
echo - they should not have any trailing slashes "\"
endlocal--
Holla.

Rajesh,
You wrote:
What does "%~2!flnm!" mean?I admit, this is not something for which you can get help by yourself looking into the documentation. One cant straight away know where the help is for this.
Anyway, here is the answer:%~2 expands %2 removing any surrounding quotes (")
You find this under the help for the call command. (call /?)
So, %~2!flnm! = (Second parameter with its surround quotes removed) appended to (the environment variable flnm as calculated while executing this line of the script)
You will find help for !variable! in set /?
--
Holla.

Holla,
I am still confused about your code. Before I mention the spot of my confusion, remember the example I had given? There were two directories: i:\ram and i:\shyam. Let us now change that destination directory to d:\shyam. Incorporating these two directories in your code, can you modify it and post it? That should give me a better idea of how your code exactly works.

Rajesh,
I have not hard coded anything(ram or shyam) in the script.
Do you know any other programming language?
That makes our life easy to explain.1. If you are worried about the script doing any damage, just remove the /y from the xcopy command. I have reproduced it here with no /y. That is the only part that can cause any problem, if any.
Just cut and paste this script into notepad and save as, let us say c:\xcp.bat.
2. Create a test environment: Say i:\source, i:\dest and some directories and files under them.
3. Run cmd.exe and in the cmd.exe prompt, type
c:\xcp.bat "i:\source" "i:\dest"
and press enter.
let me know what happens. The only command it has is xcopy. Nothing distructive. Dont worry.
@echo off
setlocal EnableDelayedExpansion
if %2a==a goto Usage
cd %1
for /r %%a in (*) do (
set fullflnm=%%a
set flnm=!fullflnm:%cd%=!
echo f | xcopy /i/s "%%a" "%~2!flnm!"
pause
)
goto :EOF
:Usage
Echo Usage %0 Source-Directory Dest-Directory
Echo - Will copy files from Source-Directory to Dest-Directory recursively
echo - and prompt the user after each file is copied.
Echo - The directories supplied should be fully qualified with drive letter and
echo - they should not have any trailing slashes "\"
endlocal--
Holla.

Holla,
I tried your batch file. Before copying, I am prompted "Does D:\shyam\\raj\Ad.txt specify a file name
or directory name on the target" How do I get rid of this problem?
By the by, I know programming in Oracle.

Rajesh,
Do you have the "echo f" part in the below line?
echo f | xcopy /i/s "%%a" "%~2!flnm!"If not add it and check.
If you already have, please paste your batch file.--
Holla.

Holla,
My code is exactly the code you gave. I reproduce it here.
--
@echo off
setlocal EnableDelayedExpansion
if %2a==a goto Usage
cd %1
for /r %%a in (*) do (
set fullflnm=%%a
set flnm=!fullflnm:%cd%=!
echo f | xcopy /e/d/y "%%a" "%~2!flnm!"
pause
)
goto :EOF
:Usage
Echo Usage %0 Source-Directory Dest-Directory
Echo - Will copy files from Source-Directory to Dest-Directory recursively
echo - and prompt the user after each file is copied.
Echo - The directories supplied should be fully qualified with drive letter and
echo - they should not have any trailing slashes "\"
endlocal
--
In the command prompt, I typed test.bat "d:\ram" "d:\shyam"

Rajesh,
This is how it works for me.
The only prompt I get is for the pause command.
xcopy's question about file or directory is answered automatically by the script as 'f'
Is the behaviour different for you?
Do you get a prompt when xcopy is asking or
do you get a prompt saying "Press any key to continue . . ."
?
Please post the content of screen after executing the command and before you press any key for the prompt.This is what I get before I press any key.
D:\>test1 "d:\ram" "d:\shyam"
Does D:\shyam\rc.bat specify a file name
or directory name on the target
(F = file, D = directory)? f
D:\ram\rc.bat
1 File(s) copied
Press any key to continue . . .--
Holla.

Holla,
I do not know what happened in the previous instance but now your code works perfectly well. In fact, that was exactly what I wanted. I wanted xcopy to copy each file and then give a pause which your code so satisfactorily does. I will try to do some more modifications to your code and see what better I can achieve. Thanks a lot, Holla! You have been a great help!

You are welcome Rajesh,
Good to know that it is working finally.
Your appreciations is what gives us energy to participate in this forum.
You made my day.
--
Holla.

Holla,
Thanks for your response. I come here with yet another query. Here is the code.
*
@echo off
SET /P usr=Please enter the username you wish to reset the password for:
net user %usr% * /DOMAIN
pause
IF errorlevel neq 0
echo Password not changed
--
As you may have realised, this script would prompt for the user name in the domain and then the new password. Suppose, we type the wrong user name, I want to give a message that the password has not been changed. Thus, that line --
IF errorlevel neq 0
echo Password not changed
--
However, the script does not execute this line at all even if the errorlevel is not equal to zero. I deliberately typed a wrong user name and used %errortype% to show me the error count. It showed me 2. Then in that case the IF statement should be executing which it is not. Why? Can you provide me with a solution?

rajesh,
Type "If /?" and read the help.
The errorlevel can not be compared with neq.
You have to either use IF ERRORLEVEL or
use %errorlevel% if you have compare it using neq.
If ERRORLEVEL 0 (
Echo password not changed
goto SomewhereElse
)or
If %ERRORLEVEL% neq 0 (
Echo password not changed
goto SomewhereElse
)--
Holla.

Holla,
I had tried IF ERRORLEVEL 0 initially but since it did not work, I used the command I posted here. No, Holla. If ERRORLEVEL 0 (Echo password not changed) is not working. I want to know why this is happening.

Holla,
I am raking up the old issue again. Your earlier batch file executes well when I run it from the command prompt. However, my real purpose is to run the batch at startup wherein I will include actual directories in it. Taking my example of making d:\ram as the source and d:\shyam as the target, can you modify your code to include these actual directories in the batch file itself?

Rajesh,
1.
Since you want the errorlevel of net command,
check errorlevel before the pause.
Now may be it is checking errorlevel of pause command.
2.
If you want to use the batch file with no parameters, just replace %1 and %2 (sometimes %~2) with the hardcoded directory names.
Since now it does not take the parameters, the usage part is also not needed.here is the modified script:
@echo off
setlocal EnableDelayedExpansion
cd /d D:\ram
for /r %%a in (*) do (
set fullflnm=%%a
set flnm=!fullflnm:%cd%=!
echo f | xcopy /y/i/s "%%a" "D:\shyam!flnm!"
pause
)--
Holla.

Holla,
You were absolutely right about the pause command. The second query about copying files from Ram to Shyam folder is also working fine but with a minor glitch. I give my code here:
*
@echo off
setlocal EnableDelayedExpansion
SET count=0cd /d i:\ram
goto start:start
FOR /f "tokens=*" %%G IN ('dir i:\ram /b') DO (call :s_do_sums)
goto end:end
SET cnt=0
for /r %%a in (*) do (
set fullflnm=%%a
set cnt=%cnt%+1
set flnm=!fullflnm:%cd%=!
rem echo %flnm%xcopy /e /y "%%a" "i:\shyam!flnm!"
echo Doing Backup %cnt% of %count% files
pause
):s_do_sums
set /a count=%count% + 1
*
Say, there are three files in folder ram.
The idea is to display a message "Doing backup 1 out of 3 files" after the first file is copied, "Doing backup 2 out of 3 files" after the second file is copied and so on. The total count of files is achieved in the start procedure. The end procedure should give us the current number of the file being copied. However,set cnt=%cnt%+1
is not incrementing cnt by one with each copy. It remains as 0 throughout the loop. I tried putting this in a call procedure but met with no success. What is wrong with the incrementing process? Can you help me with this, Holla?

Rajesh,
a few lines down, you have
set /a count=%count% + 1
Now do you know whyis not working?
set cnt=%cnt%+1--
Holla.

Holla,
I am sorry! While posting it here I just skipped mentioning /a after set. Even set /a cnt=%cnt%+1 fails to increment cnt.
Why?

Rajesh,
1. One of these should work.a) set /a cnt+=1
b) set /a cnt = !cnt! + 1
c) set /a cnt = cnt + 1
Then change the "echo doing..." line to
echo Doing Backup !cnt! of %count% files
2. You may also want to change the counting for loop: Replace('dir i:\ram /b')by('dir i:\ram /b/s')that would take care of files across subdirectories--
Holla.

Holla,
What an expert you are! That !cnt! in echo did the trick! Now it works even for the initial increment of set /a cnt = %cnt% + 1. Now tell me how it worked. How come !cnt! worked while %cnt% did not work in echo. By the by, what is that !<<variable>>! mean?

Rajesh,
type "set /?" at command prompt and try whether you can follow what it says.
couple of pages down in the "set /?" it says:Finally, support for delayed environment variable expansion has been
added. This support is always disabled by default, but may be
enabled/disabled via the /V command line switch to CMD.exe. See CMD /?Delayed environment variable expansion is useful for getting around
the limitations of the current expansion which happens when a line
of text is read, not when it is executed. The following example
demonstrates the problem with immediate variable expansion:set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "%VAR%" == "after" @echo If you see this, it worked
)would never display the message, since the %VAR% in BOTH IF statements
is substituted when the first IF statement is read, since it logically
includes the body of the IF, which is a compound statement. So the
IF inside the compound statement is really comparing "before" with
"after" which will never be equal. Similarly, the following example
will not work as expected:set LIST=
for %i in (*) do set LIST=%LIST% %i
echo %LIST%in that it will NOT build up a list of files in the current directory,
but instead will just set the LIST variable to the last file found.
Again, this is because the %LIST% is expanded just once when the
FOR statement is read, and at that time the LIST variable is empty.
So the actual FOR loop we are executing is:for %i in (*) do set LIST= %i
which just keeps setting LIST to the last file found.
Delayed environment variable expansion allows you to use a different
character (the exclamation mark) to expand environment variables at
execution time. If delayed variable expansion is enabled, the above
examples could be written as follows to work as intended:set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "!VAR!" == "after" @echo If you see this, it worked
)set LIST=
for %i in (*) do set LIST=!LIST! %i
echo %LIST%--
Holla.

Holla,
In the example which set help command gives, the variable used is the same. Like in the IF statement variable var is given two values and you use !var! to compare the second value of "after". But in my example, there are two different variables viz; count and cnt. Then, why is there a need to use the ! sgin for cnt? Can you explain in a very simple language?

Rajesh,
It is beyond my intelligence to understand the reasoning behind Micro$oft's implementation of variable expansion,
What matters is that -
if you want your variables to work as exptected,
use !variable! from the second time onwards.--
Holla.

Holla,
I am troubling you with one more query. In my example of xcopy, the first for loop gets a count of the entire list of files to be copied. The second for loop shows the current number of files being copied. However, there is a minor discrepancy. The xcopy count includes only that of files being copied while it excludes folders. For instance, we have a folder ram. Inside ram folder, there are say, two txt files and a folder called raj. My xcopy count shows the count as only two (which are those txt files) and excludes the folder count that is raj. Whereas the first for loop (dir /b /s ...) shows the count as three as it includes the folder raj. How do I rectify this?

Rajesh,
When the chappal does not fit the feet, cut the feet to make it fit the chappal.
Change the counting for loop "dir /b/s" to
"dir /a-d/s/b i:\ram"dir /a-d means it will list only files.
Since xcopy is invoked for file copy only,
there is no way to introduce a number when copying folder.There is another approach.
Make both the for loops similar.
You are using for /f for counting
and for /r for xcopying.
changing the counting for loop to "for /r", i.e.,
for /r in (*) DO (call :s_do_sums)
- will do.--
Holla.

Holla,
Issuing the dir /a-d/s/b command is not solving the problem. For some folders it works perfectly but for some folders there is some difference. I fail to understand which file the xcopy is excluding or if there is something wrong in the count.
I am not able to apply your second approach: for /r in (*) DO (call :s_do_sums). Let me explain the reason. Suppose you had only one folder say, ram then you can do the following:
cd /d d:\ram
for /r in (*) DO (call :s_do_sums).
Here, * would take files from d:\ram.
But if you want to include multiple folders like d:\ram d:\abc d:\cef etc., how do you specify that in the for /r loop?

Rajesh,
Let me rephrase your problem as I understand:
You are able to copy files as you want, but
you are not able to calculate the total
number of files appropriately.
Is the problem statement OK?In that case, It is possible to use
use similar loop in both cases.
While countin, instead of xcopy,
use cnt=!cnt!+1 thing...--
Holla.

Holla,
I am able to copy the files properly. What happens is that the xcopy count is sometimes less than the total number of files I get using dir /a-d/s/ command. I am not able to rectify this. I will give a sample code of mine once again here.
@echo off
setlocal EnableDelayedExpansion
SET count=0
SET cnt=0
:start
FOR /f tokens=* IN ('dir d:\forms d:\reports d:\script /a-d/s/b') DO (call :s_do_sums)
pause
:formscd /d d:\forms
for /r %%a in (*) do (set /a cnt+=1
set fullflnm=%%aset flnm=!fullflnm:%cd%=!
echo f| xcopy /e /y /d "%%a" "s:\backup1\forms\!flnm!" > nul
cls
echo Copied file no. !cnt! of %count% files
):script
cd /d d:\script
for /r %%a in (*) do (
set /a cnt+=1
set fullflnm=%%a
set flnm=!fullflnm:%cd%=!
echo f| xcopy /e /y /d "%%a" "s:\backup1\script\!flnm!" > nul
cls
echo Copied file no. !cnt! of %count% files
)
:reportscd /d d:\reports
for /r %%a in (*) do (
set /a cnt+=1
set fullflnm=%%aset flnm=!fullflnm:%cd%=!
echo !cnt! !flnm!
echo f| xcopy /e /y /d "%%a" "s:\backup1\reports\!flnm!" > nul
cls
echo Copied file no. !cnt! of %count% files)
:s_do_sums
set /a count=%count% + 1
*
Here what happens is that the total number of files (with the variable count) comes to around 2056 and the total number of files copied using xcopy (with the variable cnt)comes to 2043. It is this discrepancy that I am not able to resolve. You are free to edit this code and post it here.

Holla,
Is there any DOS command for window positioning? Say, when a command prompt window is opened I want to position it at the top of the screen from a batch file. How do I do it?

Rajesh,
You can download a free utility called nircmd (http://www.nirsoft.net/utils/nircmd.html) and the invoke it like
nircmd win setsize ititle "cmd.exe" 10 10 500 500
to position the cmd.exe window ....--
Holla.

Rajeesh,
dir d:\forms d:\reports d:\script /a-d/s/b
takes hidden files into account.
where are for /r (*) ... does not take hidden files into account.
that is why xcopy copies less files. Hidden files are not copied.
Based on whether you want to copy hidden files or not, you can modify the xcopy or counting part.
for example,
for /r %%a in (forms reports scripts)do (
for /r %%b in (%%a\*) do :call s_do_sums
)
- will take care of multiple directories counting. But as I said, this excludes hidden files. So you need to decide whether to use for /r or for /f based on your requirements of copying hidden files and use the same statement in both the places.since this has taken too many posts, and I am not sure whether anyone else is interested,
i suggest further discussions you take it over email. hollap at gmail dot com.--
Holla.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |