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:
- Find file MOCA command
- Internal Tables
- 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:

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.
- Find file MOCA command

2. Internal Tables

3. Execute OS command

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
OR
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.