For .... in loop

Z

zino

I don't know if I'm hitting the right group, if not can somebody tell me
which group to post in.


I need to use Eseutil utility from Microsoft Exchange sever to copy a large
folder(120 gig).
Eseutil does not accept * character, therefore I need to use it in a " for
..... in" DOS command.

the root folder to copy from contains subfolders and files and the subfolder
too contains subfolders and files. (each subfolder contains multi level of
subfolders and files with different extensions)


I need to use something as the following :

myRootFolder> for /R %I in (.) do for /D %K in ("%I") do mkdir %K
for /F %G in (dir %K /A:-D /B) do Eseutil /Y \\server1\c$\%G
/D\\server2\d$\%G

the command above is not correct. But what I'm trying is:
1- loop into each folder
2- get the folder name and create an empty similar one on the target(has the
same name)
3- fetch all the files under this folder
4- use Eseutil to copy the files one by one

thanks for help
 
P

Pegasus \(MVP\)

zino said:
I don't know if I'm hitting the right group, if not can somebody tell me
which group to post in.


I need to use Eseutil utility from Microsoft Exchange sever to copy a
large
folder(120 gig).
Eseutil does not accept * character, therefore I need to use it in a " for
.... in" DOS command.

the root folder to copy from contains subfolders and files and the
subfolder
too contains subfolders and files. (each subfolder contains multi level of
subfolders and files with different extensions)


I need to use something as the following :

myRootFolder> for /R %I in (.) do for /D %K in ("%I") do mkdir %K
for /F %G in (dir %K /A:-D /B) do Eseutil /Y \\server1\c$\%G
/D\\server2\d$\%G

the command above is not correct. But what I'm trying is:
1- loop into each folder
2- get the folder name and create an empty similar one on the target(has
the
same name)
3- fetch all the files under this folder
4- use Eseutil to copy the files one by one

thanks for help

A server or a scripting group would be a better place to post
this question. As a starting point, consider this:
- The for /R construct is reported to be buggy.
- Executing such complex commands by retyping them won't
get you far. You should put them into a batch file.
Try this one:
01. @echo off
02. set Source=d:\Exchange
03. set Target=\\Server2\d$
04. set Letter=%Source:~0,2%
05.
06. dir /ad /b /s "%source%" > c:\dir.txt
07. xcopy /s /t /e "%Source%" "%Target%\"
08. for /F "delims=" %%a in ('type c:\dir.txt') do call :Sub %%a
09. del c:\dir.txt
10. goto :eof
11.
12. :Sub
13. set Dir=%*
14. call set Dir=%%Dir:%Letter%=%%
15. echo Eseutil /Y "%*\Mailbox Database.edb" /D"%Target%%Dir%Mailbox
Database.edb"

Adjust Lines #01 and #02 to suit your requirements, then run the batch
file. When you're happy with the result, activate the batch file by
removing the word "echo" in Line #15. Note that Line #07 creates the
target directory structure. No need to do a recursive directory walk!
 
B

Big Al

zino said:
I don't know if I'm hitting the right group, if not can somebody tell me
which group to post in.


I need to use Eseutil utility from Microsoft Exchange sever to copy a large
folder(120 gig).
Eseutil does not accept * character, therefore I need to use it in a " for
.... in" DOS command.

the root folder to copy from contains subfolders and files and the subfolder
too contains subfolders and files. (each subfolder contains multi level of
subfolders and files with different extensions)


I need to use something as the following :

myRootFolder> for /R %I in (.) do for /D %K in ("%I") do mkdir %K
for /F %G in (dir %K /A:-D /B) do Eseutil /Y \\server1\c$\%G
/D\\server2\d$\%G

the command above is not correct. But what I'm trying is:
1- loop into each folder
2- get the folder name and create an empty similar one on the target(has the
same name)
3- fetch all the files under this folder
4- use Eseutil to copy the files one by one

thanks for help
for %a in (*.*) do dir %a

.. is not a valid filename, I know what . is, but every recursive
directory has no 'files' that match . So *.* works better. Or I
would guess it does.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top