Sample of batch script

  Because MultiPar consists of PAR clients and GUI, it is possible to use a PAR client from Command prompt. Read a manual of command line to the details of command and option. It's available by batch file (or command script).

  Below are some samples of batch file for Windows 7. Copy & paste the whole lines into a text file. Modify the options for PAR2 files, and set the path of par2j.exe. Write absolute path like;
SET par2_path="C:\something directory\MultiPar\par2j.exe"
Read manuals (Command_***.txt) to know the detail of options. Read Windows OS 's help for Command prompt's usage.

  Save a sample script to a file like "batch.bat" or "batch.cmd". To specify path of files or folders, Drag & Drop them on the batch file. When you put a shortcut icon of the batch file in "SendTo" menu, you can call the batch file by selecting files then Righ-Click & SendTo.

  If you want to confirm the result of scripting, add "PAUSE" at the end of batch file. If you want to see how each command line is parsed, remove "@ECHO OFF" at the top of batch file, or add "ECHO" in front of the questionable line. These may help you understanding how batch script works.

  If you want to switch flow by the result, you may use a special environment variable "ERRORLEVEL". "if ERRORLEVEL number task~" means that the task will start when ERRORLEVEL is greater than or equal to the number. "if not ERRORLEVEL number task~" means that the task will start when ERRORLEVEL is less than the number. It's possible to refer the value by using "%ERRORLEVEL%". The code is such like "set err = %ERRORLEVEL%". When you want to refer ERRORLEVEL in "for ~ do ~" loop, you must set a local variable as "setlocal enabledelayedexpansion" and use "!ERRORLEVEL!".


Index

Create individual PAR2 set in each selected folder (with GUI)
Create individual PAR2 set in each subfolder under a selected folder (with GUI)
Create one PAR2 file per each file in a selected folder
Create individual PAR2 set per each set of 4 files from many selected files
Create PAR2 recovery data and append it to each original ZIP / 7-Zip archive file

Verify and/or Repair individual PAR2 set in each selected folder with GUI

Add MD5 checksum to each file independently in a selected folder (NTFS only)
Verify each file independently by MD5 checksum in a selected folder (NTFS only)

Play sound for notification

Batch script after MultiPar GUI 's Creation
Batch script after MultiPar GUI 's Verification / Repair

Create individual PAR2 set in each selected folder (with GUI)

command"path of batch file" "path of folder1" "path of folder2" "path of folder3"...
inputspecify some folders
actionThis sample creates individual PAR2 set in each selected folder. For example, when you supply 7 folders, total 7 PAR2 set are made. It is possible to show GUI for setting, too.

  If you want to use MultiPar GUI for setting, you may call MultiPar.exe instead of par2j.exe. When a GUI is closed, next GUI is opened with next folder. You may set an option in "Automated tasks" to close GUI automatically after creation.

  If you don't want to wait the finish of each creation, you may use "START" command in the script. Because all MultiPar GUIs will open at once for each folder, you can start each creation anytime.


Create individual PAR2 set in each subfolder under a selected folder (with GUI)

command"path of batch file" "path of a folder"
inputspecify a folder
actionThis sample creates individual PAR2 set in each subfolder under the selected folder. For example, when there are 7 subfolders, total 7 PAR2 set are made.

  Don't remove an option /fo in the command-line. By this option, PAR2 file contains files only in each subfolder.

  If you want to use MultiPar GUI for setting, you may call MultiPar.exe instead of par2j.exe. When a GUI is closed, next GUI is opened with next folder. You may set an option in "Automated tasks" to close GUI automatically after creation. You must check "Don't search subfolders" option in "Client behavior", then each PAR2 set ignores files in other subfolders.


Create one PAR2 file per each file in a selected folder

command"path of batch file" "path of a folder"
inputspecify a folder
actionThis sample creates one PAR2 file per each file in the selected folder. If there is a subfolder in a folder, files in the subfolder are searched, too. Instead of creating PAR2 files for all files in a subfolder like previous sample, this creates one PAR2 file per each file in a subfolder. For example, when there are 7 files in the folder, total 7 PAR2 files are made.

  Don't remove an option /in in the command-line. By this option, index file isn't created.


Create individual PAR2 set per each set of 4 files from many selected files

command"path of batch file" "path of file1" "path of file2" "path of file3" "path of file4" "path of file5"...
inputspecify many files
actionThis sample creates individual PAR2 set per each set of 4 files from many selected files. For example, when you supply 11 files, total 3 PAR2 set are made. (11 = 4 + 4 + 3)

  You may modify this sample to accept more files up 9. Be careful about the number of source files and "SHIFT" per each step.


Create PAR2 recovery data and append it to each original ZIP / 7-Zip archive file

command"path of batch file" "path of archive file1" "path of archive file2" "path of archive file3"...
inputspecify some ZIP / 7-Zip archive files
actionThis sample creates PAR2 recovery data and append it to each original ZIP / 7-Zip archive file. Though ZIP / 7-Zip archive don't have a feature of recovery record, parchive can add the extra feature. For example, when you supply 7 archive files, total 7 archive files with recovery record are made.

  Don't remove options /ri and /in in the command-line. By this option, index file isn't created and filename has fixed volume number. When joinning original archive and recovery data, it is important to put original archive at first, then append recovery data at the last. From the nature of ZIP / 7-Zip archive, appended PAR2 recovery data has no effect to extract or decompress. If you want to keep PAR2 file separately, comment out the line of "DEL" command.

  To verify the archive, just Drag&Drop it onto MultiPar short-cut icon. (or right-click SendTo or ShellExtension works, too.) On the MultiPar GUI, the archive with PAR2 recovery data is shown as "Appended" status, when the original part of archive is complete. If you repair the archive, the archive returns to the original form. (appended PAR2 recovery data is removed.) When you want to keep the PAR2 recovery data, you need to un-check an option "Delete damaged files after Repair". Then the recovery data is renamed by adding ".1" after filename.


Verify and/or Repair individual PAR2 set in each selected folder with GUI

command"path of batch file" "path of folder1" "path of folder2" "path of folder3"...
inputspecify some folders
actionThis sample call MultiPar GUI for individual PAR2 set in each selected folder. For example, when you supply 7 folders, GUI are opened 7 times one by one. It is possible to repair by the GUI. When a GUI is closed, next GUI is opened with next PAR2 set.

  The key is setting the PAR filename to be based on the folder name. If you set prefix/suffix to filename at creating time, you need to set same one at verifying time.


Add MD5 checksum to each file independently in a selected folder (NTFS only)

command"path of batch file" "path of a folder"
inputspecify a folder
actionThis sample adds MD5 checksum to each file independently in a selected folder. If there is a subfolder in a folder, files in the subfolder are searched, too. This uses "Alternate Data Stream" and works over NTFS only. Checksum data is saved in an alternate stream "original filename:digest.md5", but it's invisible by Windows Explorer.

  There are some cautions. Some binary/text editor seems to remove alternate data stream automatically at over-writing. If you modify a file, you will need to re-add checksum to the new file again. Adding checksum will update files' modification time, even though original file data isn't changed. A user needs to use a special tool to see/delete/copy the stream, because those streams are untouchable by Windows Explorer. While an alternate stream is kept at copy/move between NTFS drives, it will be removed on other file system. For example, you cannot backup data in alternate stream on CD/DVD.


Verify each file independently by MD5 checksum in a selected folder (NTFS only)

command"path of batch file" "path of a folder"
inputspecify a folder
actionThis sample verify each file independently by MD5 checksum in a selected folder. If there is a subfolder in a folder, files in the subfolder are searched, too. This uses "Alternate Data Stream" and works over NTFS only. Checksum data must have been saved in an alternate stream "original filename:digest.md5".


Play sound for notification

  This sample plays sound by Media Player. This is good to notify the end of process to user, while running script. This can play any file format which is supported by Media Player.


Batch script after MultiPar GUI 's Creation

  MultiPar GUI can start script after creation. The script file must be "auto_c.cmd" in the user's "save" folder. A user may write any script in this file. The script gets two parameters from GUI as below;
%1 = Path of a recovery file
%2 = Path of base directory of source files

  This sample script moves created PAR2 recovery files into another folder.


Batch script after MultiPar GUI 's Verification / Repair

  MultiPar GUI can start script after verification or repair. The script file must be "auto_v.cmd" in the user's "save" folder. A user may write any script in this file. The script gets three parameters from GUI as below;
%1 = Path of a recovery file
%2 = Path of base directory of source files
%3 = Exit code of the used client (refer the command-line manual)

  This sample script opens ZIP or 7-Zip archive only when it is complete. To use this script, you need to create some recovery files for an archive at first. At that time, the key is setting the base filename to be same as the source file like;
source file's name = something.zip
recovery files' name = something.zip.par2, something.zip.vol0+4.par2, something.zip.vol4+8.par2
Thus, when you open the index file "something.zip.par2", the filename without last extension becomes the name of source file.

  This sample script moves log file (MultiPar.ini) to PAR2 file's directory. If there is an old log file already, it appends new log after existing one. To use this script, you need to enable log. MultiPar Options -> [Client behavior] -> Check "Log output of clients".