2010-10-09

Enumerator - File-exist testing program

Utility Download: Enumerator.exe - A batch driven file-exist utility that can set Return-Codes against a list of files. Handy for testing batch downloads.






I needed to test a directory to see if 30 mainframe files were downloaded properly. If all files were present, then a batch scheduler would kick off the next step in a process. Testing this many files in a standard BATCH program would be tedious. To help out, I wrote a simple program called the "Enumerator."

Enumerator is a DOS (console) application which accepts list of passed filenames. If each filename in the list is found, the program sets a return-code of 00. This code can be tested in a downstream batch process, as illustrated below.


This is a free program, no license or registration required.
Developed in C#.
Runs as a DOS or Windows program.
You are welcome to download and use.



Enumerator.exe

From the Keyliner Public GDrive site, click this link and open the folder:
download Enumerator.exe

When saving the file, the location does not need to be on the path.
Instructions for Use:

Command-line Summary:
Enumerator.exe /? Help
Enumerator.exe c:\path\parameterfile.lst

1. Using an ascii text editor (Notepad), build a test input-parameter file, listing one filename per line. For example C:\data\parameter.lst:

;Test Enumerator Parameter File
;use Semicolons for comments

;Wildcards are supported


C:\data\testfile1.doc

C:\data\testfile2.xls
D:\subfolder\*.xls
\\server\share\folder\somefile.txt


Close and save the file to a known location. For example, "C:\Data\Parameter.lst"

2. Open a command-prompt (DOS Prompt); Start-Run, "CMD".

3. Change to the directory where Enumerator.exe was saved. For example:

CD "\Program Files\Util"

4. Type this command, all on one line:

enumerator.exe "C:\data\parameter.lst"

Use quotes if the filename or path contains embedded spaces.
Press enter to run.


Results:

DOS ErrorLevels
00 = All files detected
89 = One or more files were not discovered
99 = Startup/parameter error

The DOS screen SYSOUT will also report a summary of the findings. Be aware this may not be visible in a batch process, depending on how it is called.


Optionally launch in this manner:
"C:\Program Files\Util\Enumerator.exe" "C:\data\parameter.lst" >c:\data\log.txt

where results are recorded to a log.txt file, which can be reviewed with Notepad. Return-codes are set as before.


TESTING in a BATCH File:

Consider this sample batch file (C:\data\test.bat) for testing:

@Echo off
CLS
@echo Enumerator %1 %2 %3
@Echo.
enumerator.exe "C:\data\parameters.txt"
IF "%ERRORLEVEL%"== "99" GOTO PARMERR
IF "%ERRORLEVEL%"== "89" GOTO FAIL
IF "%ERRORLEVEL%" == "0" GOTO GOOD

:ParmErr
Echo Bad parameter file
Echo Use Enumerator.exe for syntax
Echo.
PAUSE
GOTO END

:Fail
Echo.
Echo Some files not found
Echo.
PAUSE
REM Remove PAUSE statement for production
GOTO End


:Good
Echo.
Echo All files accounted for....
Echo.
PAUSE
REM Remove PAUSE statement for Production
GOTO END

:END


Additional Notes:
The processor running enumerator must be logged in as a user with adequate rights to see the files being tested.

Leave a comment if you found this program useful.

No comments:

Post a Comment

Comments are moderated and published upon review. (As an aside, not a single spam has been allowed through; why bother?)