(view source code of airregncmd.bat as plain text)
@ECHO OFF
IF "%~1"=="" GOTO Syntax
IF NOT "%~2"=="" GOTO Syntax
ECHO.%~1| FINDSTR.EXE /R /X /I /C:"N[0-9][0-9]*[0-9A-Z]*" >NUL 2>&1 || GOTO Syntax
IF NOT EXIST MASTER.txt IF NOT EXIST "%~dp0MASTER.txt" GOTO Download
IF NOT EXIST ACFTREF.txt IF NOT EXIST "%~dp0ACFTREF.txt" GOTO Download
SETLOCAL ENABLEDELAYEDEXPANSION
SET NNumber=%~1
SET NNumber=%NNumber:~1%
IF EXIST MASTER.txt (SET Master=MASTER.txt) ELSE (IF EXIST %~dps0MASTER.txt SET Master=%~dps0MASTER.txt)
IF EXIST ACFTREF.txt (SET AcftRef=ACFTREF.txt) ELSE (IF EXIST %~dps0ACFTREF.txt SET AcftRef=%~dps0ACFTREF.txt)
REM Loop through the MASTER table to find the manufacturer/model code for the specified N-number
FOR /F "tokens=1,3 delims=," %%A IN (%Master%) DO (
IF %NNumber% EQU %%A (
REM The N-number is recognized, now loop through the ACFTREF table to convert the manufacturer/model code to meaningful text
SET Found=1
FOR /F "tokens=1-3 delims=," %%C IN (%AcftRef%) DO (
IF %%B EQU %%C (
SET Aircraft=N%NNumber%
REM Trim trailing whitespace from manufacturer name
FOR %%F IN (%%D) DO (
SET Aircraft=!Aircraft! %%F
)
REM Trim trailing whitespace from aircraft model
FOR %%F IN (%%E) DO (
SET Aircraft=!Aircraft! %%F
)
ECHO.!Aircraft!
ENDLOCAL
EXIT /B 0
)
)
)
)
ENDLOCAL
REM This part of the code will only be reached if the aircraft wasn't found, hence returncode 2
EXIT /B 2
:Download
ECHO.
ECHO This script requires the FAA Aircraft Registry's Releasable Aircraft Database files in the current directory.
ECHO Download and unZIP the files and restart this script in the directory where the unZIPed files are located.
ECHO https://www.faa.gov/licenses_certificates/aircraft_certification/aircraft_registry/releasable_aircraft_download/
ECHO.
CHOICE.EXE /C YN /T 5 /D N /M "Do you want to open the download page now"
IF %ErrorLevel% EQU 1 (
START https://www.faa.gov/licenses_certificates/aircraft_certification/aircraft_registry/releasable_aircraft_download/
ECHO.
ECHO Download and unZIP the database file, then restart this
ECHO script in the directory where the unZIPed files are located.
ECHO.
)
EXIT /B 3
:Syntax
ECHO.
ECHO AirRegNCmd.cmd, Version 1.00 for Windows
ECHO Search downloaded FAA registry database files for the specified aircraft
ECHO registration number ^("N-number"^)
ECHO.
ECHO Usage: AirRegNCmd.cmd Nxxx
ECHO.
ECHO Where: Nxxx is a valid aircraft registration "N-number", e.g. N18906
ECHO.
ECHO Example: AirRegNCmd.cmd N18906
ECHO will return:
ECHO N18906 LOCKHEED 12A
ECHO.
ECHO Notes: This script requires the FAA Aircraft Registry's releasable
ECHO aircraft database files either in the current directory or in this
ECHO script's parent directory. The database files can be downloaded at:
ECHO https://www.faa.gov/licenses_certificates/aircraft_certification
ECHO /aircraft_registry/releasable_aircraft_download/
ECHO You will be prompted to open the download page if the database
ECHO files aren't found.
ECHO Neither this script nor its author are associated with the FAA.
ECHO This script's return code ^("errorlevel"^) will equal 0 if the
ECHO specified aircraft registration was found, 2 if it wasn't,
ECHO 3 if the database files weren't found, 1 on command line errors.
ECHO.
ECHO Written by Rob van der Woude
ECHO https://www.robvanderwoude.com
EXIT /B 1
page last modified: 2024-04-16; loaded in 0.0068 seconds