Difference between revisions of "OS4X plugin os4xplugin filerename"

From OS4X
Jump to navigation Jump to search
Line 46: Line 46:
  
 
== Examples ==
 
== Examples ==
 +
=== incl. directories ===
 
All examples are based on an OS4X send job with number 76, addressed to company "c-works":
 
All examples are based on an OS4X send job with number 76, addressed to company "c-works":
 
  /opt/os4x/tmp/%r/os4x_job_%j/
 
  /opt/os4x/tmp/%r/os4x_job_%j/
Line 60: Line 61:
 
which will compute to:
 
which will compute to:
 
  /opt/os4x/data/2008/03/18/76
 
  /opt/os4x/data/2008/03/18/76
 +
 +
=== only filename ===
 +
The following configurations will rename the file in its current directory. The example is based on one job with filename "testfile.txt":
 +
 +
%f_%j
 +
will compute to:
 +
testfile.txt_76
 +
----
 +
%F_%j%G
 +
will compute to:
 +
testfile_76.txt
 +
----
 +
%e__%F_%j%G
 +
will compute to:
 +
c-works__testfile_76.txt
  
 
== Return values ==
 
== Return values ==

Revision as of 12:27, 29 April 2014

Purpose

Rename all files of an OS4X job according to a specific rule.

Requirements

  • File /etc/os4x.conf or configuration file pointed to in environment variable $OS4X_CFGFILE. Via the used configuration file, the information are retrieved used by the plugin (such as default configuration etc.).
  • Either source file or renamed target file must exist. If none of these exist, the plugin stops execution.

Configuration

The target filename can be set up to contain variables. These variables are exchanged by runtime information of the OS4X job, in which context the plugin is run.

Target name can contain an absolute path information or a file name only. The plugin will react on this situation dynamically:

  • absolute path information: the calculated target path will be created dynamically
  • file name only (without path information): the file will be renamed in the same path it resided before

The usable variables are:

  • %j: job number
  • %d: day of job creation (two digits)
  • %m: month of job creation (two digits)
  • %Y: year of job creation (four digits)
  • %H: hour of job creation (two digits, 24h format)
  • %M: minute of job creation (two digits)
  • %S: second of job creation (two digits)
  • %D: job direction: "incoming" or "outgoing"
  • %r: recipient partner shortname
  • %s: sender partner shortname
  • %t: recipient location name
  • %u: recipient department name
  • %v: recipient first name
  • %w: recipient family name
  • %x: recipient address code
  • %g: sender location name
  • %h: sender department name
  • %i: sender first name
  • %J: sender family name
  • %k: sender address code
  • %e: depending on the job direction, the company shortname of the external communication partner:
    • incoming jobs: sender's company shortname (= "%s")
    • outgoing jobs or undefined job direction: recipient's company shortname (= "%r")
  • %E: file extension (the text after the last dot, "."), i.e. "txt"
  • %G: file extension (the text after the last dot, ".", including the last dot "."), i.e. ".txt"
  • %f: filename (basename only, without path)
  • %F: filename without extension (basename only, without path)

Examples

incl. directories

All examples are based on an OS4X send job with number 76, addressed to company "c-works":

/opt/os4x/tmp/%r/os4x_job_%j/

will compute to:

/opt/os4x/tmp/c-works/os4x_job_76

/opt/os4x/tmp/%D/%r/%j

will compute to:

/opt/os4x/tmp/outgoing/c-works/76

A SWAN-like directory behaviour would be:

/opt/os4x/data/%Y/%m/%d/%j

which will compute to:

/opt/os4x/data/2008/03/18/76

only filename

The following configurations will rename the file in its current directory. The example is based on one job with filename "testfile.txt":

%f_%j

will compute to:

testfile.txt_76

%F_%j%G

will compute to:

testfile_76.txt

%e__%F_%j%G

will compute to:

c-works__testfile_76.txt

Return values

0: everything OK

1: Configfile (/etc/os4x.conf or value of environment variable "OS4X_CFGFILE", read in as file) cannot be found or database unavailable.

2: License error

3: XML parameter file cannot be parsed

4: Files cannot be renamed