Related Documentation Download this Manual
PDF (US Ltr) - 2.1Mb
PDF (A4) - 2.1Mb


5.2.2.1 File Name, Pattern and Prefix Examples

This is a series of examples that demonstrate the use of name, pattern and prefix. For simplicity, this ignores the file location details.

A directory with the name input contains 204 files:

  • 100 files with names in a sequence from file00.tbl to file99.tbl.

  • 104 files with names in a sequence from fileaa.tbl to fileaz.tbl, fileba.tbl to filebz.tbl, fileca.tbl to filecz.tbl, and fileda.tbl to filedz.tbl.

Use a prefix to load all 204 files from the input directory:

"file": [{"prefix": "input/"}]

Use one or more name to load individual files that do not fit into a convenient sequence:

"file": [{"name": "input/file25.tbl"}, {"name": "input/fileck.tbl"}]

Use a regular expression pattern to load specific file name sequences. The regular expression syntax states that certain characters require an escape character, see: Regular Expression Syntax.

The escape character is the backslash character, and it is a reserved character in both JSON and MySQL. Therefore, it is necessary to escape the backslash character twice, and specify \\ for JSON, and \\ for MySQL.

However, the regular expression escape sequence depends upon the NO_BACKSLASH_ESCAPES SQL mode:

  • Use \\. to escape a period if NO_BACKSLASH_ESCAPES is enabled.

  • Use \\\\. to escape a period if NO_BACKSLASH_ESCAPES is not enabled. The following examples use this sequence because it is the default mode.

To load all 100 files with a numeric suffix:

"file": [{"pattern" : "input/file\\\\d+\\\\.tbl"}]

To load all 104 files with an alphabetical suffix:

"file": [{"pattern" : "input/file[a-z]+\\\\.tbl"}]

To load 10 files, file00.tbl, file10.tbl ... file90.tbl:

"file": [{"pattern" : "input/file\\\\d0\\\\.tbl"}]

To load 24 files, fileaa.tbl to fileaf.tbl, fileba.tbl to filebf.tbl, fileca.tbl to filecf.tbl, and fileda.tbl to filedf.tbl,

"file": [{"pattern" : "input/file[a-d][a-f]\\\\.tbl"}]