Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for midititl.bat

(view source code of midititl.bat as plain text)

  1. @ECHO OFF
  2. :: Check Windows version
  3. IF "%OS%"=="Windows_NT" (SETLOCAL) ELSE (GOTO Syntax)
  4. VER | FIND "Windows NT" >NUL && GOTO Syntax
  5.  
  6. :: Check command line arguments
  7. IF "%~1"=="" GOTO Syntax
  8. IF NOT EXIST "%~1" GOTO Syntax
  9. :: For NT4 without Resource Kit, replace FINDSTR.EXE /E /I by FIND /I
  10. ECHO.%*| FINDSTR.EXE /E /I ".mid" >NUL 2>&1 || GOTO Syntax
  11.  
  12. :: Check if STRINGS.EXE is available and if not, offer to download it
  13. SET StringsAvailable=
  14. SET Download=
  15. (STRINGS.EXE /? 2>NUL) | FIND "Mark Russinovich" >NUL
  16. IF ERRORLEVEL 1 (
  17. 	SET StringsAvailable=No
  18. 	ECHO This batch file requires SysInternal's STRINGS untility.
  19. 	SET /P Download=Do you want to download it now? [y/N] 
  20. )
  21.  
  22. :: Start download if requested
  23. IF /I "%Download%"=="Y" (
  24. 	START "Strings" "http://www.sysinternals.com/ntw2k/source/misc.shtml#strings"
  25. 	ECHO.
  26. 	ECHO Install the downloaded file and make sure STRINGS.EXE is in the PATH.
  27. 	ECHO Then try again.
  28. )
  29.  
  30. :: Abort if STRINGS.EXE is not available yet
  31. IF "%StringsAvailable%"=="No" GOTO End
  32.  
  33. :: OK, finally, let's list the MIDI titles
  34. FOR %%A IN (%*) DO (
  35. 	CALL SET Title=
  36. 	FOR /F "tokens=*" %%a IN ('STRINGS.EXE -A -N 5 "%%~A" ^| MORE /E ^+5') DO CALL :Parse "%%~a"
  37. 	IF DEFINED Title (
  38. 		ECHO.
  39. 		CALL ECHO%%Title%%
  40. 	)
  41. )
  42.  
  43. :: Done
  44. GOTO End
  45.  
  46.  
  47. :Parse
  48. SET Title=%Title% %~1
  49. GOTO:EOF
  50.  
  51.  
  52. :Syntax
  53. ECHO.
  54. ECHO MidiTitl.bat,  Version 1.01 for Windows NT 4 [2] / 2000 / XP
  55. ECHO Display the titles of the specified MIDI files
  56. ECHO.
  57. ECHO Usage:  MIDITITL  filespec.MID
  58. ECHO.
  59. ECHO Where:  filespec  is the (list of) MIDI file(s); wildcards are allowed,
  60. ECHO                   but filespec.MID should always end with .MID
  61. ECHO.
  62. ECHO Notes:  [1]  This batch file requires SysInternals' STRINGS utility, available
  63. ECHO              at http://www.sysinternals.com/ntw2k/source/misc.shtml#strings
  64. ECHO              You will be prompted to download STRINGS if it isn't found.
  65. ECHO         [2]  This batch file uses FINDSTR, which is a native command in Windows
  66. ECHO              2000 and XP, but requires the Resource Kit for Windows NT 4.
  67. ECHO              Read the comments in this batch file for modifications required
  68. ECHO              for Windows NT 4 without Resource Kit.
  69. ECHO.
  70. ECHO Written by Rob van der Woude
  71. ECHO http://www.robvanderwoude.com
  72.  
  73. :End
  74. IF "%OS%"=="Windows_NT" ENDLOCAL
  75.  

page last modified: 2024-04-16; loaded in 0.0183 seconds