Unix: /usr/etc/venture/bin/import
Windows: C:\Program Files\Xinet\Venture\bin\import
In this example, we copy a folder called Images from one server to another. On the original server,
Images was in
/raid/2014/. On the new server, it will be on
/Volumes/Imports/OSX/CustomerData. A database tracked the location of files and metadata on the original server. The goal, now, is to copy the file to the new server and import the metadata into Xinet, associating it with the correct files:
/raid/2014/Images,textshort1,tttteeeeeexxxxxxtttttloooonnngggg1,
3/15/2014,2014/3/15 11:11:11 AM,25,251,250001,25.52,1,
Bylinetest1,25
/raid/2014/Images/Dalim Demo,textshort2,tttteeeeeexxxxxxttttt-
loooonnngggg2,3/15/2014,2014/3/15 11:11:11 AM,25,252,250002,25.52,1,Bylinetest2,25
/raid/2014/Images/Dalim Demo/4A.dct,textshort3,tttteeeeee-
xxxxxxtttttloooonnngggg3,3/15/2014,2014/3/15 11:11:11 AM,25,253,250003,25.52,1,Bylinetest3,25
textshort (16 chars)
textlong (60 chars)
date4 (the 4th date listed in Administration view
)
date18 (the 18th)
int1 (1 byte integer)
int2 (2 byte integer)
int4 (4 byte integer)
float (float)
boolean (boolean)
Byline (IPTC text)
Urgency (IPTC tiny int)
tip: You may want to make a script that contains your test import command. Typically one has to run the command a few times to work out syntax errors. Putting the command in a file and running the file as a script allows you to edit the command more easily than retyping everything at the command-line prompt.
– Run cmd, directing output to a log file so you can see any debugging messages:
An import command to handle the example export file above would look like this.
“export.txt” In our example, the name of the file containing the exported database. In real life, you can name the file anything you choose.
-onlyexisting The import will only match files that have records in the database already. If the file can't be found, no new (or “virtual”) entry is made.
If neither flag is used, the import program will match with existing records if they can be found, and make new records if they cannot be found.
-s2c Hex value of the separator between each column in a record. In this case, a comma is the separator.
On Unix systems, the command
od -x will provide this value for you. See
od(1) for details. On Windows systems, use a Hex editor to determine the value.
-r0A The hex value of the separator between each record. Typically that’s a
Return, whose hex representation is
0A.
-g73746172740a The last string (in hex) before the start of the data. In the
export.txt file, the string is
start plus a
Return (thus the final
0a).
-ipath_to_file The
-i argument means ignore the first column, for example., the path in our example. While it may seem odd to ignore the path, the path is really dealt with by the
-b argument, as explained below. The
-i argument can be used to ignore any field. The string following the
-i (
path_to_file in this case) is purely optional. It’s a good way, however, to note what is being skipped.
-ttextshort The
-t argument identifies a text-field name, as it exists in the Xinet database. In this example the field’s name is
textshort.
-ttextlong Another text field (also previously established in Xinet) called
textlong.
-ddate4’MM/DD/YYYY’:def=09/20/1972
Delineates a date field called
date4 that uses the format in the quotes. The
def= value provides the default to be used when the exported data doesn’t contain a value. A default is optional.
-tByline A text field that happens to be an IPTC field.
-uUrgency An integer field that happens to be an IPTC field
The goal of the -b argument is to construct the paths to all the files being imported. Without knowing the path to the file, the import command will not attach metadata.
The two %
signs surround a variable. A number within those signs stands for a field number in the export file.
1 stands for the 1st field,
2 for the second field, and so on. Thus,
%5% refers to the fifth field, and the value of that field will be substituted in place of the
%5% If field 5 has the path to the file and its name, this would be the field number to use.
Note for Windows
When using the import command interactively, for example., on the command-line, use only one percent sign on each side of the field number, e.g.,
%5%. When scripting a
.bat file, however, use double percent signs on each side of the field, e.g.,
%%5%%.
A number followed by a c means to “clear” that number of characters from the string with which the field number was associated. For example,
%10c5% means to substitute in the value of the fifth field, but remove the first ten characters of the string. If the fifth field's value is
/raid/data/Customers/, then
%10c5% would evaluate to
/Customers/.
An m means to convert the path format of the string from the Macintosh style to the Unix style. The Macintosh style use colons to separate folders while Unix uses forward slashes. The
m converts to the Unix style. An example of using it in conjunction with the clear flag would be:
%10cm5%.
Multiple fields can be specified within the two % signs. For instance,
%5%%6%%7% is a valid argument. This can be useful if the path to the file is not in one field but split into several fields. The path can be “constructed” in this manner.
Remember that we had a folder called Images which we moved to the new server. We placed it in
/Volumes/Imports/OSX/CustomerData, the new home for
Images. Xinet copied all the file information into its database at the time the files were moved onto the server. The old server had the images in
/raid/2014/Images. An example record from the export file would show:
The -b argument begins with the part of the path that will be common to all the imported files:
The second part of the location, Images/Dalim Demo/4A.dct, is specified by
%10c1%. Here, the final
1 is a variable representing the first field in the export file. For this sample record, the value is
/raid/2014/Images/Dalim Demo/4A.dct. The
10c tells the import program to skip the first 10 characters in that string. So
/raid/2014 is stripped out, leaving
/Images/Dalim Demo/4A.dct. The program places this string after
/Volumes/Imports/OSX/CustomerData, giving us the grand result:
/Volumes/Imports/OSX/CustomerData/Images/Dalim Demo/4A.dct
In this case, the images are not actually moved to the server. Instead, they will appear as archived files with the nearline tag in Xinet. Users will be able to see the file names, characteristics, previews, and metadata. Let’s say that the old server had the
Images directory located at
/Volumes/Test/OPI Testing. On the new server, we want the “archived files” to appear under
/raid/CustomerData/Archives. Here is how to proceed:
/Volumes/Test/OPI Testing/Images,8001,7001,6001,11/11/11 11:11:11 AM,22/22/22 22:22:22 AM,33/33/33 33:33:33 AM,..CT,8BIM,
textshort1tttteeeeeexxxxxxtttttloooonnngggg1,03/15/2014,2014/03/15 11:11:11 AM,25,251,250001,25.52,1,Bylinetest1,25
/Volumes/Test/OPI Testing/Images/alias EPS,8002,7002,6002,11/11/11 11:11:11 AM,22/22/22 22:22:22 AM,33/33/33 33:33:33 AM,..CT,8BIM,textshort2,tttteeeeeexxxxxxttttt-
loooonnngggg2,03/15/2014,2014/03/15 11:11:11 AM,25,252,250002,25.52,1,Bylinetest2,25
/Volumes/Test/OPI Testing/Images/alias EPS/cmykepsbinarywithpath,8003,7003,6003,11/11/11 11:11:11 AM,22/22/22 22:22:22 AM,33/33/33 33:33:33 AM,..CT,8BIM,textshort3,tttteeeeee-
xxxxxxtttttloooonnngggg3,03/15/2014,2014/03/15 11:11:11 AM,25,253,250003,25.52,1,Bylinetest3,25
3.
|
Construct the import call or execution, using the appropriate arguments.The arguments are largely the same as in Case 1, but there are new flags you might want to use.
|
-onlynew If this flag is used, the
import program will only match files that did not have records in the database. This will make all new (or “virtual”) records.
If neither flag is used, the import program will match with existing records if they can be found, and make new records if they cannot
be found.
-m <date definition string>’[:def=<default value>] (file modified date)
Here’s a sample import command, where the import file is called
export.txt:
An archive media other than IMPORTED can be specified with the
-mMediaName flag. The only criteria is that the
archivemedia record for the
MediaName already exist in Xinet.
•
|
There is a -preflight flag that will parse the export file but not take any action. Xinet highly recommends using this flag before doing a real import.
|
•
|
There is a -D flag for debugging, which is useful if the import command fails to find metadata fields or files. If a file can’t be found, the debugging file will show something like: File /Volumes/California/Imports/OSX/CustomerData/Images/file_list is not in the database, skipping record.
|
•
|
There is an -ignoredataerrors that will proceed with the import regardless of errors.
|
•
|
There is an -ignoremissingfields that will also proceed with the import regardless of errors.
|
•
|
If you run import without any arguments, you’ll get a usage summary.
|
•
|
The import command expects the language character set of the data being imported to be the same character set used by the Xinet database. By default, Xinet uses Latin1, which is sufficient for most European language strings. If the export file is also in the Latin1 character set, then the import command does not need to do anything special to handle the special characters. Likewise, a database using SJIS will have no trouble importing an export made in SJIS.
|
•
|
The -A flag is used to import archive information about files. It is useful for migrations from one server to another.Typically, you would export this information from a Xinet server into a file using the export command. The export command writes all the required information in the required format. If that data needs to be preserved on the new server, simply adding the -A flag to the import command will be enough.
|
The final <tab> in this example marks the end of this field. The final
0x00 is necessary at the end of the field.
<archive date in unix time>, <media id>, <archive number>, <size>, <thumbnail offset>, <thumbnail size>, 0x00;<archive date in unix time>, <media id>, <archive number>, <size>, <thumbnail offset>, <thumbnail size>, 0x00...<tab>