Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for exifinfo.bat

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

  1. @ECHO OFF
  2. IF    NOT "%OS%"=="Windows_NT" GOTO Syntax
  3. IF        "%~1"=="/?"   GOTO Syntax
  4. IF        "%~2"==""     GOTO Syntax
  5. IF    NOT "%~4"==""     GOTO Syntax
  6. IF    NOT EXIST "%~1"   GOTO Syntax
  7. IF /I     "%~2"=="/X"   GOTO XML
  8. :: Because we cannot easily sort a FOR loop, we'll just call this same batch file
  9. :: again with an additional /U switch (Unsorted) and use SORT on its unsorted output
  10. IF /I "%~2"=="/L" IF "%~3"=="" (
  11. 	FOR %%A IN ("%~1") DO (
  12. 		ECHO "%%~fA"
  13. 		"%~f0" "%%~fA" /L /U | SORT
  14. 		ECHO.
  15. 	)
  16. 	GOTO:EOF
  17. )
  18. IF /I     "%~2"=="/L" IF /I     "%~3"=="/U" GOTO ListAll
  19. IF /I     "%~2"=="/L" IF /I NOT "%~3"=="/U" GOTO Syntax
  20. IF /I NOT "%~2"=="/L" IF    NOT "%~3"==""   GOTO Syntax
  21.  
  22.  
  23. FOR %%A IN ("%~1") DO CALL :GetValue "%%~fA" "%~2"
  24. GOTO:EOF
  25.  
  26. :GetValue
  27. FOR /F "tokens=3,4 delims=<:>" %%A IN ('TYPE "%~f1" ^| FINDSTR /R /B /I /C:" *<[a-z/][^>]*:[^>]*>" ^| FIND /I ":%~2>"') DO ECHO "%~f1"	%%A=%%B
  28. GOTO:EOF
  29.  
  30. :ListAll
  31. FOR /F "tokens=3 delims=<:>" %%A IN ('TYPE "%~f1" ^| FINDSTR /R /B /I /C:" *<[a-z][^>]*:[^>]*>.*</[a-z][^>]*:[^>]*>"') DO (
  32. 	IF NOT "%%~A"=="li" IF NOT "%%~A"=="li xml" ECHO.%%A
  33. )
  34. ECHO.
  35. GOTO:EOF
  36.  
  37. :XML
  38. FOR %%A IN ("%~1") DO (
  39. 	ECHO "%%~fA"
  40. 	ECHO.
  41. 	TYPE "%%~fA" | FINDSTR /R /B /I /C:" *<[a-z/][^>]*:[^>]*>"
  42. 	ECHO.
  43. )
  44. GOTO:EOF
  45.  
  46. :Syntax
  47. ECHO.
  48. ECHO EXIFInfo.bat,  Version 0.51 BETA for Windows NT
  49. ECHO Return the requested EXIF value for the specified file(s),
  50. ECHO or list all available tag names and, optionally, values.
  51. ECHO.
  52. ECHO Usage:  EXIFINFO   imagefile  exiftag
  53. ECHO    or:  EXIFINFO   imagefile  /L
  54. ECHO    or:  EXIFINFO   imagefile  /X
  55. ECHO.
  56. ECHO Where:  imagefile  the image(s) to check (single filespec, wildcards allowed)
  57. ECHO         exiftag    is a valid EXIF tag name (e.g. Model, ExposureTime)
  58. ECHO         /L         list all valid EXIF tag names for imagefiles
  59. ECHO         /X         list all EXIF metadata for imagefiles in XML format
  60. ECHO.
  61. ECHO Written by Rob van der Woude
  62. ECHO http://www.robvanderwoude.com
  63.  
  64. IF "%OS%"=="Windows_NT" EXIT /B 1
  65.  

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