Script Tool: Process Scene Releases Version 2.0

Categories: Tools
Tags: No Tags
Comments: No Comments
Published on: August 17, 2009

I wrote in march about how to package a scene release properly. In that post I also published the source of a release creation batch script called ProcRel.bat. I wrote a heavily modified and extended version of that script and present it to you here and today.

NOTE: This Script does not work for SINGLE ZIP release files. It will stop after it created the RAR archive. I have to take a look at it, because it is a minor flaw that does not have to be there, even though it is not the scripts purpose to create releases that are just a single ZIP archive.

Bug Fixes

The script had a bunch of short comings and even a bug. I have not figured out yet what the criteria is for the command line version on WinRAR to create volume numbers of multiple file archives one digit long and when it uses two digits (E.g. FILE.part1.RAR versus FILE.part01.RAR). My old batch assumed 01 instead of the single digit version, but that creates an issue, if RAR decides to use the single digit naming convention instead.

My new version covers this and checks for both versions and then uses the correct one appropriately when it continues by renaming the RAR archives to FILE1.RAR or FILE01.RAR respectively and ZIP Archives afterwards.

Other Minor Enhancements

Also improved was the speed, by utilizing a temporary work directory, which is used to dump all files for each ZIP archive to create the ZIP in one step, without the need to update it with each file (NFO, File_ID.DIZ etc.).

Also included is now the option to include an optional INTO executable.

Major Enhancement 1

But all those changes are minor compared to the really good stuff. The batch does now require a FILE_ID.DIZ template instead of the final File_ID.DIZ file itself. The template should include place holders for the total # of files of the release and a place holder for the current file number. Those place holders will then be replaced by the script automatically with the proper values E.g. [1/10] , [2/10] …. [10/10] etc.

Hell Yeah! It was about time!

Major Enhancement 2

The second major change is that you do not have to mess around with the code of the BATCH file anymore, not do you have to memorize stupid command line parameters to call the script.

All configuration is now done via a separate .INI file. Once you set everything correctly there, you simply execute the Batch either from the command prompt or by double clicking it in Windows Explorer. Simple as?? that. :)

I am also so nice this time and let you download the code, including a sample .INI file, file_id.diz (that you can upload it to scene FTP servers or old-school bulletin boards, if you want to), a ReadMe.txt help and documentation text file and a neat little intro for RoySAC.com hehe.

Download the Code Here (ZIP Format) – Backup Download via MediaFire.com

Requirements

You still require the following 3rd party programs, which are not part of this tool (same thing as with the previous version of this tool, nothing new).

  • WinRAR, including its Command Line Version RAR.EXE
  • WinZip Command Line (NOT included in Standard WinZip Release)
    The File is called WZZIP.EXE and should be located in your Winzip program directory

Usage

Copy the following 2 files into the directory where you would like to create the Release Archive Files:

  • ProcRel2.bat
  • ProcRel.ini

Open the ProcRel.ini file and modify the parameters as needed.
Once you updated the INI file properly, simply execute the ProcRel2.BAT script
(from the MS DOS Command prompt or simply via double clicking on it in Windows Explorer)

Important Notes!


The batch was not tested for Windows file names. I suggest to use always the short path (DOS 8.3 Name)
The Parameter Names and Section Name in the INI file are “Case-Sensitive” = DON’T CHANGE THEM
Unlike Standard INI Files, do not add spaces before or after the = character which separates the PARAMETER NAME from the VALUE

Correct:
PARAM1=whatever

INCORRECT (might causes BATCH to fail)
PARAM1 = whatever

The RAW INI File Looks like this

[SETTINGS]
ZipExe=
RARExe=
NFOFile=
FILEID=
INTROEXE=
BASEFILENAME=
RAROPT=
RARVOLSIZE=
RAREXTRA=
INPUTDATA=
RARFiles=
IFFILEEXISTS=

The INI Parameters

All Parameter are required, except for INTROEXE and RAREXTRA
If RARFiles has any value except for KEEP (case-sensitive), DEL is assumed as value
If IFFILEEXISTS has any other value than ABORT (case-sensitive), OVERWRITE is assumed as value

ZipExe

Path and File Name to Command Line Version of WinZip
If you installed WinZip to the default directory, the value is probably:
C:\PROGRA~1\WinZip\WZZIP.EXE

RARExe

Path and File Name to the Command Line Version of WinRAR
If you installed WinRAR to the default directory, the value is probably:
C:\PROGRA~1\WinRAR\RAR.EXE

NFOFile

Path and File Name to the NFO file that you want to include with every Release ZIP File
The Path is not required, if you copy the NFO file into the work directory, together with the BAT and INI
Example Values:
RoySAC.nfo
– or-
C:\NFOS\REL1\RoySAC.nfo

FILEID

The path and file name to the template file for the FILE_ID.DIZ
If you copy this file into the work directory, do NOT call it FILE_ID.DIZ or FILE_ID.WRK. It will cause the BATCH to Fail. The Template can contain 2 place holders, which will be replaced by the BATCH at run-time with the actual values.

CURRENTFILE = This string will be replaced with the current archive volume E.g. 1,2,3 … XX
TOTALFILES = This string in the template will be replaced with the total number of archives that will be created

The Batch copies the Template FILE_ID to the work directory with the Name FILE_ID.WRK and substitutes the string TOTALFILES in it with the actual number of archives created. Then it re-creates the FILE_ID.DIZ for each archive and replaces CURRENTFILE with the number of the current archive.

INTROEXE

Path and File Name of the Intro Executable that you would like to include with every archive, if you have one.

BASEFILENAME

The base file name for your RAR and ZIP archives.?? No other Characters than a-z, A-Z,0-9 and the dash (-) and Underscore (_) are allowed. No Spaces, no special Characters. Remember, this is a scene release that you would like to create. The Base File Name will be automatically extended by the archive volume number (1,2,3 …XX or 01,02 …0X) and the extension (.RAR and .ZIP)

RAROPT

The main RAR option. The Default is “a”, which you should only change, if you want to move the original uncompressed release files into the Archives. In that case, you should use the vale “rn” (without the double quotes) instead. I do not recommend doing this though.

RARVOLSIZE

Specifies the VOLUME size of the archives. You don’t want to create just a single gigantic archive, right?
The parameter is specified without the “-” that you would include, if you call RAR from the command line.
It is simply “vXXXXk” or “vXXXXb” where the Xs stand for a number. Depending on the last character being “k” or “b”, the meaning of the number is either “(k)ilobytes” or “(b)ytes”

Examples:
v98078k = creates volumes of a bit less than 100 MB to fit on a ZIP-100 disk
v4096k = 4 MB etc.

RAREXTRA

Additional RAR command line options that you might want to add.
The default value is: -m5 -r
The meaning of those two parameters is:

-m5??
sets the compression level. 5 is maximum, you can also set it to 0,1 .. 4 which is faster

-r

includes files in Sub Directories

INPUTDATA

The Path and File Name Filter for the files to be included in the release.
Keep in mind to use the short path for the directory location.
Do not forget the filer, which is typically “*.*”

Example:
C:\DIR\DYPMZA~B\*.*

RARFiles

The default is DEL, meaning that the RAR archives that were created by the BATCH will be deleted, once the Final ZIP archive was created for it. If you would like to keep the RAR archives for any reason, set the value to KEEP (case-sensitive)

IFFILEEXISTS

Use ABORT (case-sensitive), if you would like the batch to abort, if it finds ZIP files with the same BASENAME in the current working directory. This would prevent that you re-create a release, if you had already done so. However, it would also abort, if the ZIP files belong to an incomplete or aborted processing batch. The default is OVERWRITE, which means that the batch deletes all ZIP files with a matching BASENAME in the current
WORK DIRECTORY.

Copyright

This program is FREEWARE! You are free to USE, COPY and even MODIFY it as you see FIT. You are using it at your own risk.

Important Disclaimer & Legal Notice!

The author, of this software accepts no responsibility for damages resulting from the use of this product and makes no warranty or representation, either express or implied, including but not limited to, any implied warranty of merchantability or fitness for a particular purpose.

This software is provided “AS IS”, and you, its user, assume all risks when using it.

The Source Code

Download the Code Here (ZIP Format)- Backup Download via MediaFire.com

   1:  @ECHO OFF
   2:  CLS
   3:  REM =================================================
   4:  REM Please Change Name and Path for the Following Variables
   5:  REM =================================================
   6:  SETLOCAL ENABLEDELAYEDEXPANSION
   7:  call:READINI SETTINGS ZipExe
   8:  call:READINI SETTINGS RARExe
   9:  call:READINI SETTINGS NFOFile
  10:  call:READINI SETTINGS FILEID
  11:  call:READINI SETTINGS INTROEXE
  12:  call:READINI SETTINGS BASEFILENAME
  13:  call:READINI SETTINGS RAROPT
  14:  call:READINI SETTINGS RARVOLSIZE
  15:  call:READINI SETTINGS RAREXTRA
  16:  call:READINI SETTINGS INPUTDATA
  17:  call:READINI SETTINGS RARFiles
  18:  call:READINI SETTINGS IFFILEEXISTS
  19:  Echo ---------------------------------------------------------
  20:  Echo ProcRel.INI Parameters
  21:  Echo ---------------------------------------------------------
  22:  Echo ZipExe=%ZipExe%
  23:  Echo RARExe=%RARExe%
  24:  Echo NFOFile=%NFOFile%
  25:  Echo FILEID=%FILEID%
  26:  Echo INTROEXE=%INTROEXE%
  27:  Echo BASEFILENAME=%BASEFILENAME%
  28:  Echo RAROPT=%RAROPT%
  29:  Echo RARVOLSIZE=%RARVOLSIZE%
  30:  Echo RAREXTRA=%RAREXTRA%
  31:  Echo INPUTDATA=%INPUTDATA%
  32:  Echo RARFiles=%RARFiles%
  33:  Echo IFFILEEXISTS=%IFFILEEXISTS%
  34:  Echo ---------------------------------------------------------
  35:  IF NOT EXIST %NFOFile% goto NONFO
  36:  IF NOT EXIST %FILEID% goto NODIZ
  37:  set /a zipf=0
  38:  IF "%IFFILEEXISTS%"=="ABORT" (
  39:     FOR %%Z in (%BASEFILENAME%??.ZIP) DO (
  40:       GOTO ZIPSFOUND
  41:     )
  42:  ) ELSE (
  43:     Del /Q "%BASEFILENAME%??.zip"
  44:     Echo Delete "%BASEFILENAME%??.zip"
  45:  )
  46:  Echo Delete "%BASEFILENAME%.part??.rar" (they should not be there though)
  47:  DEL /Q "%BASEFILENAME%.part??.rar"
  48:  REM =================================================
  49:  Echo Create RAR Archives %1.partXX.RAR for Data Selection %2
  50:  %RARExe% %RAROPT% -%RARVOLSIZE% %RAREXTRA% "%BASEFILENAME%" "%INPUTDATA%"
  51:  REM =================================================
  52:  Echo Rename %BASEFILENAME%.partXX.RAR to %BASEFILENAME%xx.RAR
  53:  set /a pos=0
  54:  For /f %%x in ('dir /on /b "%BASEFILENAME%.part*.rar"') do (
  55:    set /a pos+=1
  56:  )
  57:  if %pos%==0 goto NORAR
  58:  IF NOT EXIST "WORKDIR" MkDir "WORKDIR"
  59:  For /L %%n in (1,1,%pos%) do (
  60:    call :RenRAR %BASEFILENAME% %%n
  61:  )
  62:  Echo.
  63:  Echo =================================================
  64:  Echo %pos% RAR volumes were created!
  65:  Echo =================================================  
  66:  Echo Build List of RAR Archives in Folder...
  67:  dir /B /A:-D *.RAR >!RARFiles.txt
  68:  REM =================================================
  69:  Echo Process RAR Archives...
  70:  Set REP1=TOTALFILES
  71:  IF EXIST "FILE_ID.WRK" DEL /Q "FILE_ID.WRK">NUL
  72:  Call:SandR %FILEID% FILE_ID.WRK %REP1% %pos%
  73:  SET FCNT=0
  74:  Set REP2=CURRENTFILE
  75:  FOR /F "delims=|" %%i IN (!RARFiles.txt) DO (
  76:      Echo Processing %%i
  77:      Set /a FCNT+=1
  78:      IF EXIST "FILE_ID.DIZ" DEL "FILE_ID.DIZ">NUL
  79:      Call:SandR FILE_ID.WRK FILE_ID.DIZ %REP2% !FCNT!
  80:      IF EXIST "%%i.ZIP" del "%%i.ZIP">NUL
  81:      DEL /Q WORKDIR\*.*>NUL
  82:      MOVE "%%i" "WORKDIR\%%i">NUL
  83:      IF EXIST "%NFOFile%" COPY "%NFOFile%" WORKDIR\>NUL
  84:      IF EXIST "FILE_ID.DIZ" COPY "FILE_ID.DIZ" WORKDIR\>NUL
  85:      IF EXIST "%INTROEXE%" COPY "%INTROEXE%" WORKDIR\>NUL
  86:       %ZipExe% -a "%%i.ZIP" "WORKDIR\*.*"
  87:      IF "%RARFiles%" == "KEEP" (MOVE WORKDIR\*.RAR>NUL)
  88:      DEL /Q WORKDIR\*.*>NUL
  89:  )
  90:  REM =================================================
  91:  Echo Build List of TEMP ZIP Files...
  92:  Dir /b *.RAR.ZIP>!ZIPfiles.txt
  93:  REM =================================================
  94:  Echo Rename ZIP Files...
  95:  REM =================================================
  96:  FOR /F "delims=." %%i IN (!ZIPfiles.txt) DO (
  97:      Echo Rename %%i.RAR.ZIP to %%i.ZIP
  98:      IF EXIST "%%i.ZIP" del "%%i.ZIP"
  99:      REN "%%i.RAR.ZIP" "%%i.ZIP"
 100:  )
 101:  REM =================================================
 102:  Echo Deleting TEMP Files...
 103:  IF EXIST !ZIPfiles.txt Del /Q !ZIPfiles.txt
 104:  IF EXIST !RARfiles.txt Del /Q !RARfiles.txt
 105:  IF EXIST "FILE_ID.WRK" DEL /Q "FILE_ID.WRK">NUL
 106:  IF EXIST "FILE_ID.DIZ" DEL /Q "FILE_ID.DIZ">NUL
 107:  RmDir WORKDIR>NUL
 108:  ECHO =================================================
 109:  ECHO Done!
 110:  ECHO =================================================
 111:  Echo.
 112:   Pause
 113:  goto END
 114:  ??
 115:  REM =============================================
 116:  REM PROCESSING FUNCTIONS
 117:  REM =============================================
 118:  :READINI
 119:  Set key=%~2
 120:  call:strLen key len
 121:  Set /a "len+=1"
 122:  set yfs=
 123:  set ymn=
 124:  for /f "tokens=*" %%i in ( ProcRel.ini ) do (
 125:    set ywv=%%i
 126:    if /i "!ywv!"=="[%1]" (
 127:       set yfs=Y
 128:     ) else (
 129:       set ywv=!ywv:~0,%len%!
 130:       if defined yfs (
 131:          if not defined ymn (
 132:            if /i "!ywv!"=="%2=" ( 
 133:              set ymn=%%i
 134:              set ymn=!ymn:~%len%!
 135:            )
 136:          )
 137:       )
 138:     )
 139:  )
 140:  Set %~2=%ymn%
 141:  GOTO :EOF
 142:  REM =============================================
 143:  :strLen -- returns the length of a str, max 1023
 144:  ::      -- %~1: in - varible name of a string variable
 145:  ::      -- %~2: out- string length
 146:  SETLOCAL
 147:  set str=A!%~1!
 148:  set len=0
 149:  set /a n=1024
 150:  set /a n^>^>=1, len+=n
 151:   if !str:~%len%!. == . set /a len-=n
 152:  set /a n^>^>=1, len+=n
 153:   if !str:~%len%!. == . set /a len-=n
 154:  set /a n^>^>=1, len+=n
 155:   if !str:~%len%!. == . set /a len-=n
 156:  set /a n^>^>=1, len+=n
 157:   if !str:~%len%!. == . set /a len-=n
 158:  set /a n^>^>=1, len+=n
 159:   if !str:~%len%!. == . set /a len-=n
 160:  set /a n^>^>=1, len+=n
 161:   if !str:~%len%!. == . set /a len-=n
 162:  set /a n^>^>=1, len+=n
 163:   if !str:~%len%!. == . set /a len-=n
 164:  set /a n^>^>=1, len+=n
 165:   if !str:~%len%!. == . set /a len-=n
 166:  set /a n^>^>=1, len+=n
 167:   if !str:~%len%!. == . set /a len-=n
 168:  set /a n^>^>=1, len+=n
 169:   if !str:~%len%!. == . set /a len-=n
 170:  ( ENDLOCAL & REM RETURN VALUES
 171:      IF "%~2" NEQ "" SET %~2=%len%
 172:  )
 173:  GOTO:EOF  
 174:  REM =============================================
 175:  :SandR
 176:  REM Search And Replace
 177:  SETLOCAL
 178:  for %%i in (%1) do (
 179:    for /f "tokens=1,* delims=]" %%a in ('"type %%i|find /n /v """') do (
 180:      set "line=%%b"
 181:      if defined line (
 182:          call set "line=echo.%%line:%3=%4%%"
 183:          for /f "delims=" %%X in ('"echo."%%line%%""') do %%~X>>%2
 184:      ) ELSE echo.>>%2
 185:  )
 186:  )
 187:  ENDLOCAL
 188:  goto :eof
 189:  REM =================================================
 190:  :RenRAR
 191:  IF EXIST "%1.part%2.rar" ( 
 192:       ren "%1.part%2.rar" "%1%2.RAR"
 193:       echo ren "%1.part%2.rar" "%1%2.RAR"
 194:  ) else (
 195:     IF EXIST "%1.part0%2.rar" ( 
 196:         ren "%1.part0%2.rar" "%10%2.RAR"
 197:         echo ren "%1.part0%2.rar" "%10%2.RAR"
 198:      )
 199:  )  
 200:  GOTO :EOF
 201:  ??
 202:  REM =================================================
 203:  REM ERROR MESSAGE FUNCTIONS
 204:  REM =================================================
 205:  :NORAR
 206:  echo.
 207:  Echo Error!
 208:  echo Error! No RAR Archives with the file names
 209:  echo %BASEFILENAME%.partXX.RAR
 210:  echo were Created!
 211:  goto END
 212:  REM =================================================
 213:  :NONFO
 214:  echo.
 215:  Echo Error!
 216:  echo NFO-File %NFOFile% not found!
 217:  goto END
 218:  REM =================================================
 219:  :NODIZ
 220:  echo.
 221:  Echo Error!
 222:  echo File_ID.DIZ Template File NOT Found at %FILEID%
 223:  goto END
 224:  REM =================================================
 225:  :ZIPSFOUND
 226:  echo.
 227:  Echo Error! (ABORT Parameter specified)
 228:  Echo Current directory contains already one or more ZIP files 
 229:  Echo with the name: %BASEFILENAME%??.ZIP 
 230:  goto END
 231:  REM =================================================
 232:  :END
 233:  REM Finished!
 234:  Echo.
 235:  Goto :EOF


Download the Code Here (ZIP Format) – Backup Download via MediaFire.com

Okay, that’s it. I hope that you find this little tool/script helpful and practical. As I mentioned indirectly, feel free to spread the ZIP archive around (I would actually appreciate, if you would do so).

Cheers!

Carsten aka Roy/SAC