IMail - Batch file to copy rules.ima to all user directories

Product: Version: Platform:
IMail All NT,Win2000,XP

Answer/Solution: Here is are two examples of a Batch file to copy rules.ima to all user directories. They use standard NT commands with no additional utilities:

Note that you will need to make a directory named master and put your master rules.ima file there. As written here it will find all users in the users directory. 

 ----------- Begin of batch listing -----------
@echo off

echo.
echo This batch copies the file .\master\rules.ima
echo into all subdirectories. It has to be started from
echo the root of any of your mail domain's directories.
echo.
pause

rem building userlist based on directory only
dir /B /AD users>dirlist.txt
echo.>rulecopy.log

echo Please wait while the file is copied ...

rem copy the source file to each directory
rem Note that this command must all be on one single line:
FOR /F "eol= tokens=1,* delims=/" %%i in (dirlist.txt) do echo %%i>>rulecopy.log && copy .\master\rules.ima .\users\"%%i" >>rulecopy.log

type rulecopy.log
echo.
echo Check file rulecopy.log for details.
echo.

:END
 ----------- End of batch listing -----------


This example is simpler:

For /R d:\IMail\Users %%I IN (.) DO COPY d:\IMail\Users\rules.ima %%I\rules.ima

For /R d:\IMail\Users %%I IN (.) DO COPY d:\IMail\Users\spambox.Fwd %%I\spambox.Fwd

Here the rules would direct filtered messages to sub-mailboxes named spambox. The .Fwd files will forward the messages from the spambox sub-mailboxes to the user you name in spambox.Fwd.

If your spambox.fwd file points to an account named abuse. Make sure that you delete the .fwd file from the abuse user directory after running the bat file (You can add the command to the bat file itself) or you have just created a very nasty little mail loop:

del d:\imail\users\abuse\*.fwd

Document #:   Revision Date:
IM-20000523-DM02   06/14/04

Return To KnowledgeBase Search Page