Posts Tagged ‘Command line’

Command line fun, part two

Posted in October 19, 200915:17hTim StrehleNo Comments »

This DC-X command line made me smile today (I’m doing batch data imports at a customer site):

xsltproc custom_xml_to_dcx.xslt input.xml | php /opt/dcx/bin/dcx_import.php –app default – | php /opt/dcx/bin/dcx_export.php –app default -t document – -r ‘$job = new DCX_Job($obj->app); $job->setWorkflow(“recreate_previews”); $job->setStatus(DCX_Job::STATUS_TODO); $job->addDocument($obj->getId(), “input”); $job->save(); echo $obj->getId() . ” => ” . $job->getId() . “\n”;’

It may look intimidating, but it’s rather simple – an XML input file (actually coming from our old DC4 product here) is formatted as DC-X XML using XSLT. dcx_import.php creates a DC-X document record from that XML (it copies the files referenced in the XML and inserts the metadata into the DC-X database). The dcx_export.php call then runs code against the DC-X PHP API to create a job in the DC-X workflow engine for (re-)creating preview images (you can do this if there are no preview images, or – like in this case – they are too small).

Command line fun with DC-X

Posted in August 18, 200914:22hTim StrehleNo Comments »

I’m currently at a customer site, and I found that a lot of documents had data in the wrong field (“IPTC02015″ instead of “Category”). An excellent opportunity to play with the DC-X command line tools:

php /opt/dcx/bin/dcx_textquery.php –app default ‘+IPTC02015:[* TO *]‘ -m 1000 | php /opt/dcx/bin/dcx_export.php –app default -t document – | sed ‘s/IPTC02015>/Category>/g’ | php /opt/dcx/bin/dcx_update.php –app default -

This invocation performs a fulltext search for all documents which have the field “IPTC02015″ set, feeds the document IDs into a script that exports these documents as XML, runs “sed” to change the field name, and uses the modified XML to update the document in the DC-X database. (The fulltext index is automatically updated.) Marvellous!