I have a job where I get a XML trigger file and several ZIP files. Within the XML file it lists all the ZIP files. What’s the best way to validate that I have all the ZIP files listed in the XML file? Is it to create a javascript or is there a easier way?
You could do this without a script, but it won’t be easier.
You’d have to branch out of the main trunk, split your XML file, and for each item listed, run a Folder Listing set to use the path/filename as a mask. The resulting XML tells you the number of files it found (along with information on each file) so you could do a quick compare against the File count node to see if it’s equal to 1.
I’m pretty certain, however, that querying the OS via FileSytemObject is going to be more efficient than all of that. If you’re comfortable with either jscript or vbscript, I’d recommend simply going that route.
Actually, you could use one of Version 2020.1’s new features: the File/Folder Condition task.
Basically, you use your XML file as the data file and you either split it into nodes or create metadata where each node is a “document” (that way, you can use the metadata sequencer, which is more efficient than splitting files when the file is a large one).
After that, it’s just a question of using the File/Folder condition task and setting the name of the file to check using a standard data selection.