Shoutbox

What would be the best way to doing this (mass .zip'ing + DIFFERENT password + log) - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: What would be the best way to doing this (mass .zip'ing + DIFFERENT password + log) (/showthread.php?tid=89992)

What would be the best way to doing this (mass .zip'ing + DIFFERENT password + log) by prashker on 03-31-2009 at 03:53 AM

So I have 1171 folders all inside a main folder (S:\Folders\)

For each folder I want it to be
-Zipped
-Passworded

But I want the passwords to be random.

For each zip file I want the name + password added into a file

Passwords.txt

<Name> | Password
<Name> | Password
<Name> | Password
<Name> | Password
<Name> | Password
<Name> | Password
<Name> | Password
<Name> | Password
<Name> | Password

Basically a quick way of referring to the zipped file and finding out it's password.

Something along those lines and something that would be automatic.

What would be the best approach, is there a program that can do this, maybe a batch file using rar.exe?

Thanks,
-Sam ;>


RE: What would be the best way to doing this (mass .zip'ing + DIFFERENT password + lo by CookieRevised on 03-31-2009 at 06:29 PM

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 /?).
RE: What would be the best way to doing this (mass .zip'ing + DIFFERENT password + log) by prashker on 03-31-2009 at 09:01 PM

I love you....(l)

Thanks :D, I'll be using this in a few days and this will cut the time needed to do it SIGNIFICANTLY :D!


RE: What would be the best way to doing this (mass .zip'ing + DIFFERENT password + log) by noir on 04-01-2009 at 07:23 PM

small tip on adding just a single pw to a single zipped rar file?