Skip to content. | Skip to navigation

Personal tools


You are here: Home / weblog / Batch-fu


Posted by Dominic Cronin at Nov 08, 2006 11:00 PM |


Today I had a problem with Tridion Content Porter. This is an application that can be used to move data in and out of the Tridion web content management system. It has an "unattended" mode of operation which allows you to run it from the command line, passing a reference to a configuration file as a parameter. I discovered that sometimes (and if anyone can tell me exactly when that is, I'd be grateful),  if you try to run it this way, instead of "blocking" it returns asynchronously and continues to run in the background, writing data to disk that you'd really rather wait for before you embark on further processing.

I called this in to customer support, but I can't wait for them to fix it, so in the meantime, I cracked my knuckles and settled down to figuring out a workaround for my batch script. This post isn't about Tridion Content Porter; this is a generic technique that you can use in batch scripts for any process that you'd like to give a chance to finish.

This (with most of the irrelevant stuff elided) is what I came up with:

REM Dump out the data using Content Porter
.... ContentPorter.exe .... config.xml .... /unattended

for /f "usebackq" %%i in (`tasklist ^| find /C "ContentPorter.exe"`) DO if /I %%i GTR 0 GOTO TEST_FOR_CONTENT_PORTER

REM do something with the exported data
So what's going on here?