To run a script file pass the –s:filename command-lineparameter or pass any filename on the command-line with a .zipsh extension. When processing a script, JZip will not normally display any GUI, unless commands in the script file invoke GUI elements (e.g. for feedback or confirmation purposes). NOTE: script files can be run from the GUI interface using the file/Run Script... menu option
It is very easy to create scripts. E.G. to create a ZIP file containing the contents of /etc, just write a script file as follows…
>/tmp/etc.zip
/etc
And that’s all there is to it. Any sting found on a line that doesn’t start with > or | is assumed to be a file or directory that should be added to the current archive. The > directive opens an archive and must appear before any files are added. When you add a directory its full contents are recursively added.
If you only want to add .java files under your home directory (/home/me), i.e. 'select only files ending in .java' whenever a directory is added.
|s:end
.java
>/tmp/myhome.zip
/home/me
Or if you only want to add all files except .class files under your home directory, i.e. 'exclude files ending in .class' whenever a directory is added.
|x:end .class
>/tmp/myhome.zip
/home/me
You can read the full syntax of the exclusionand selection commands (|x: and |s: ) below.
The scripting language has many more commands as follows. All commands, with the exception of the above two, begin with |, this is because | is an illegal character in most filesystems.
Initialize an archive. If filename does not include an
extension,
a suitable one will be added.
.zip | standard ZIP format |
.tgz | compressed tar (gzip) |
.tb2 | compressed tar (bz2) |
.xip | encrypted format |
The following characters have special meaning and are expanded into
the following strings...
~ | date YYYYMMDD format |
# | date DDMMYYYY format |
$ | date MMDDYYYY format |
% | time HHMM format |
* | user name |
|add filename-or-directoryname
This is an alternative way of specifying a file or directory to add to the archive. There is a 2nd format of this command which allows a file to be added to the archive with a completely different name (and path) as follows…
|add filename|pathname-used-on-the-archive
This usage of the |add command allows complete flexibility with the name of the file as it appears on the archive.
|manifest [filename]
This comand will add the contents of the name file as the 'manifest' of the archive. If filename is not specified, a default manifest file is added.
|flatmode true,false
This commands sets flatmode to true or false. When flatmode is true, files are added to the archive without directory information. If a file is added twice, an error message is displayed and the 2nd version of the file is not added.
|zipmode best,speed,none,default,tgz,tb2
This sets the compression mode of the archive to one of
You can use this command to change the ‘current directory’. This will influence the path-name of the file as it appears on the archive. If no directory is specified, the ‘current-directory’ is set to the initial start-up directory
|key string
This sets the encryption key to be used. If set, the archive is encrypted and will have a .xip extension. If no parameter is specified, encryption is turned off.
|close
This closes the current archive. If you don't call this command, the archive is automatically closed at the end of the script-file.
If you don’t secify a selection criteria, all files are included.
|s:end end-part-of-filename
This allows you to select files that end in certain strings. Multiple end-strings can be specified separated by a | character, e.g.
|s:end .class|.java
The above command arranges for all .class and .java files found to be added to the archive, other files are excluded. Typically, when using this command, you would specify one or more directories to add. When you add a directory, all the files it (and all subdirectories) contain are added. This commands allows you to only select certain files.
|s:start start-part-of-filename
This allows you to only include files that start with certain strings. Multiple start-strings can be specified separated by a | character. Note: this command refers to the file-name part of the path and not the path as a whole.
|s:file filename
This allows you to only include files with certain names. Multiple names can be specified separated by a | character. Note: this command refers to the file-name part of the path and not the path as a whole
|s:dir directory-segment-names
This allows you to only include files with certain directory-segment-names within the pathname. Multiple directory-segnent-names can be specified separated by a | character. E.G. you could exclude files and directories within directories named CVS by the following command…
|s:dir bin
When processing a directory, if the file contains bin as one of the path-elements, the file is included, all other files would be ignored (unless other selection commands forced their inclusion).
This allows you to exclude files that end in certain strings. Multiple end-strings can be specified separated by a | character, e.g.
|x:end .dll|.exe|.aps
The above command excludes all files that end with .dll .exe or .aps . Typically you will then go on to |add a directory.
|x:start start-part-of-filename
This allows you to exclude files that start with certain strings. Multiple start-strings can be specified separated by a | character. Note: this command refers to the file-name part of the path and not the path as a whole.
|x:file filename
This allows you to exclude files with certain names. Multiple names can be specified separated by a | character. Note: this command refers to the file-name part of the path and not the path as a whole
|x:dir directory-segment-names
This allows you to exclude files with certain directory-segment-names within the pathname. Multiple directory-segnent-names can be specified separated by a | character. E.G. you could exclude files and directories within directories named CVS by the following command…
|x:dir CVS
When processing a directory, if the file contains CVS as one of the path-elements, the file is ignored.
Display a message-box
|abort message-text
A message-box will be displayed with YES/NO buttons; if NO is selected by the user, the script will terminate. E.G.
|abort do you want to continue?
The |abort command without any arguments will simply terminate the script.
|feedback on,off
Feedack is off by default, but it is a very good idea to turn it on if you are adding a lot of files. With feedback on. A dialog box displays the names of files as they are added.
|comment comment-char
You can use this command to change the comment character, normally # represents a comment , but you can set ot to any character at all, but if you set it to a ‘|’ you won’t be able to enter any commands.
|verbose true,false
If verbose mode is false, all standard-output messages are suppressed.
This command can be used to move any file to any destination. However, it is excepted that it will be used mostly to move an archive built in one location to a final location. E.G. if you are creating a .tb2 archive that is to reside on a floppy disk, you will probably want to create the archive on a hard drive and then move it to the floppy drive when it has been created; the reason for this is that although .tb2 tends to give the best compression, it uses more space while creating the archive as the archive is created uncompressed, and then compressed 'all-in-one' when it is complete.
To make things easier, &@ can be specified as the in-file parameter, this expands to the path of the archive just written (The |close command must have already be used). Also, &* can be used in the out-file parameter, this is expanded to be the file-name part of the path of the archive just written, and &# can be used, this is expanded to the extension-part of the pathname.
A typical |mv command might be
|mv &@ a:\backup\&*
(Note, the substitutions processed by the > command are also processed in the out-file parameter, but no extension is ever added automatically to the out-file)
|cp in-file out-file
This command is like |mv except the in-file remains intact.
The
same parameter substitutions are also processed.
|rm file
Delete the named file
|status status-file
This command arranges for a status-message to be written to the named status-file
|@include-file-name
The input-stream is switched to the named file. Include-files can themselves include other files to any depth.
|call script-file
The named script file is called. The difference between calling a
script
file and including it is that all parameters set in the calling script
are cleared in the called script-file. Similarly, any parameters set in
the called script are not set when the script returns from the call.
The
@include command simply switches the input stream and restores
it at the
end of file, it is exatly as if all the commands in the included file
were
in the including file. Whereas, the call command creates a new
instance of the script-file
processor in which to run the callled script.