I'm trying to rename files using an outside counter for renaming files in PowerSwitch. There is a small XML file on drive c:, which stores the actual slot number:
.. and each of the incoming files get the slot number from here, then the counter increased and saved for later use. Here is the script expression which I enter to a basic "Rename" element's property pane:
var theName = job.getNameProper();
var theNewName, thePosition;
var theXmlDoc = new Document( "C:/Counter.xml" );
thePosition = theXmlDoc.evalToNumber("/Info/Counter"); // retrieving the original position
theNewName = thePosition;
job.log( 1, theNewName );
var theNode = theXmlDoc.evalToNode( "/Info/Counter" );
var theTextElement = theXmlDoc.createText( thePosition.toString() );
theNode.replaceChild( theTextElement, theNode.getFirstChild() );
theXmlDoc.save( "C:/Counter.xml" ); // saving the increased counter
The problem is, that the counting up is going by 2, not by 1! From the log I see that every time a job hits the Rename element, the script's running twice, therefore the resulting files are numbered like 2, 4, 6, 8 etc.
Why is it happening this way? Is it a bug or a feature? How can I run the script expression only once?
Any help appreciated.
1 post • Page 1 of 1