08:49:35
25.02.2018 (Sunday)

PathLocate

Locates files in the PATH-listed directories.

PathLocate is a small command line utility that allows you to quickly search for files located in directories listed in the PATH environment variable.

The program allows you to enter many names/masks of files on one command line, limit the number of returned files, ignore or take into account the size of characters, calculate CRC32 checksums, display the last modification time of files, their size, VersionInfo block from executable files (on Windows) and other.

License: Freeware, OpenSource.

The application does NOT contain any malicious software. VirusTotal.com scan results:
Windows 32-bit portable Windows 64-bit portable
Linux 32-bit portable Linux 64-bit portable

This program was made for my private use, but it may also be useful to someone.

PathLocate can be useful for administrators to quickly locate executable files, check their version, as well as in batch files for making decisions in the absence of any files necessary for the proper operation of the script.

Screenshots


PathLocate version 1.0 [Win 64-bit] (2018.01.25)

Usage: pathlocate.exe FILE [-c] [-of=s|w] [-n] [-s=1|0] [-l=n|X|fX|lX [--crc] [-vi] [-u] [-h] [-V] [--home]

Mandatory arguments to long options are mandatory for short options too.
Options are case-sensitive. Options in square brackets are optional.
All parameters that do not start with the "-" or "/" sign are treated as file names/masks.
Options and input files can be placed in any order, but -- (double dash)
indicates the end of parsing options and all subsequent parameters are treated as file names/masks.

Available options:

SwitchDescription
-c, --curr-dir Also searches in the current directory.
-of, --out-format=s|w Output format: s, w
  s | Simple - only file names (default)
  w | Wide - file names with additional information:
    Modification date, size in bytes, size in human readable format.
-s, --case-sensitive=1|0 Case sensitive. 1 - enabled, 0 - disabled. Default: 0 on Windows, 1 on Linux.
-l, --limit=n|X|fX|lX File count limit:
  n | none - no limit (show all files). Default.
  X - show only the first X files.
  fX | firstX - as above
  lX | lastX - show only the last X files.
--crc Calculate CRC32 checksums of found files.
-vi, --version-info Displays VersionInfo block from executable files, if available.
-u, --summary Show summary - number of files found and their total size.
-h, --help Show this help.
-V, --version Show application version.
--home Opens program homepage in the default browser.

Exit codes:

Exit codeDescription
0 Success.
1 Invalid syntax or other error.
2 No files found.

Examples

  1. Show all files from directories listed in the %PATH% environment variable:
      pathlocate.exe *
  2. Show the first 10 EXE and/or DLL files from directories listed in the %PATH% environment variable:
      pathlocate *.exe *.dll -l 10
  3. Display VersionInfo block from the msvcrt.dll file and calculate its CRC32 cheksum:
      pathlocate msvcrt.dll -vi --crc
    Result:
    D96A352D  C:\Windows\system32\msvcrt.dll
           ProductName: Microsoft® Windows® Operating System
           ProductVersion: 7.0.16299.125
           FileVersion: 7.0.16299.125 (WinBuild.160101.0800)
           FileDescription: Windows NT CRT DLL
           OriginalFileName: msvcrt.dll
           InternalName: msvcrt.dll
           CompanyName: Microsoft Corporation
           LegalCopyright: © Microsoft Corporation. All rights reserved.
    
  4. Checking in the batch file whether the 7z archiver can be run:
    
    @echo off
    
    pathlocate 7z.exe > nul
    
    if %errorlevel% EQU 0 goto LBL_ALL_OK
    if %errorlevel% EQU 1 goto LBL_ERROR
    if %errorlevel% EQU 2 goto LBL_NO_FILES
    
    :LBL_ALL_OK
    echo  All OK! The 7z.exe file exists. We can start archiving. 
    goto LBL_END
    
    
    :LBL_ERROR
    echo  Wrong syntax or another error! 
    goto LBL_END
    
    
    :LBL_NO_FILES
    echo  No 7z archiver found. Compression can not be started. 
    goto LBL_END
    
    
    :LBL_END
    echo  --------- END ----------- 
    

Tech Info

To compile program from source, you need:
  1. CodeTyphon Programming Studio or Lazarus IDE
  2. My Pascal units from units directory (in the archive with source).
How to build:
  1. Extract 7z archive with source files.
  2. Open src\PathLocate.ctpr with CodeTyphon or src\PathLocate.lpi with Lazarus.
  3. Set build mode for your destination system.

    Select menu Project -> Project Options... A new window will appear.
    In the tree view (on the left), select Compiler Options.
    At the top of this window you can select the build mode from the dropdown list.
    Choose: Release_Win32, Release_Win64, Release_Lin32 or Release_Lin64.

  4. Build project (menu Run->Build).
Tested on CodeTyphon 6.30 with FPC 3.1.1 and Laraus 1.9.0 (trunk version) with FPC 3.1.1

Changelog

Version 1.0 (2018.01.25)
Initial release.