A batch file should indeed be perfect for this one-time job....
This will do the trick:
code:
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
REM Change following line to proper WinRar path and command line tool (don't forget the quotes)
SET RAREXE="C:\Program Files\WinRAR\RAR.EXE"
DEL PASSWORDS.TXT
FOR /D %%M IN ("*.*") DO (
SET PWD=0000!RANDOM!
SET PWD=!PWD:~-5!
CALL %RAREXE% a -m5 -p!PWD! -r -ep1 "%%M.RAR" "%%M\"
ECHO %%M.RAR ^| !PWD! >> PASSWORDS.TXT
)
Save it as a batch file and put it in the directory which contains all the directories you want to archive.
Then run it from the command line.
It will create a RAR for each subdirectory with a random password.
The password will always be 5 digits long.
There is no error checking, so make sure you have enough free space for the archives.
The archived directories will NOT be deleted afterwards.
EDIT-PS: If you want the password to be longer you could replace those two SET-lines with something like:
code:
SET PWD=00000000!RANDOM!!RANDOM!
SET PWD=!PWD:~-10!
which will produce a password with 10 digits.
Change the 10 into something lower to produce a password of X digits.
%RANDOM% (and with delayed expansion enable: !RANDOM!) will produce a random number between 0 and 32767. See the help for the command SET (SET /?).