JDA WMS — Find files in a folder

Every so often, you as a MOCA developer have to find a file or files from either the log or files directory under LES, be it a trace file, an event file for something that processed through the Integrator or a label after ‘Pick Release’. For Production systems, this can mean searching through thousands and at times even hundreds of thousands of files. What’s the best way to go about it?

Well, there are a couple of ways to go about it and trust me when I say that there’s no one right way to do it — that goes for most of the trivial problems. However, do keep in mind the consequences of each solution you attempt. I will do it using the following methods:

  1. Find file MOCA command
  2. Internal Tables
  3. Execute OS command

Please note here that you should never run execute OS command for a command that has an interactive output, if you do, you’ll leave a process running in the background. See example below:

The process left running on App Server

Nevertheless, let’s continue back to finding files in a folder using a pattern. So, I’ll attach screenshots for you to see. All methods do work and you can use the execute OS command for either Windows Server or Redhat (Linux), as long as you know the correct syntax of the OS command, understand the consequence of the command you’re running and are aware of the best practices around JDA WMS Application.

  1. Find file MOCA command
Execution Time: 0.34 seconds

2. Internal Tables

Execution Time: 23.69 seconds

3. Execute OS command

Execution Time: 0.31 seconds

Each command serves a different purpose, you can query and sort based on size easily using Internal tables, or can even reuse information to write it to a file, but at a higher cost as internal tables are being used. You can use execute OS command “dir /s folder/filename” to look further into subdirectories, which would be harder and costlier using Method 1 and 2.

For Redhat (Linux) you can use the following OS commands:

locate filename or foldername


find /apps -type d -name “log” — for folder

find /apps -type f -name “rollout.pl” — for file

Please note that the locate command that comes with the mlocate package can be used for files that have been in the system for at least 24 hours, as the “updatedb” command runs every 24 hours and may not find recent files.