Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for filesys.bat

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

  1. @ECHO OFF
  2. :: Windows NT 4 / 2000 only
  3. IF NOT "%OS%"=="Windows_NT" 1 GOTO Syntax
  4.  
  5. :: Keep variables local
  6. SETLOCAL ENABLEEXTENSIONS
  7.  
  8. :: Parameter check
  9. ECHO.%1 | FIND "?" >NUL
  10. IF NOT ERRORLEVEL 1 GOTO Syntax
  11. :: Extract drive letter
  12. SET Drive=%1
  13. IF DEFINED Drive SET Drive=%Drive:~0,1%
  14. CALL :Drive %Drive%:
  15.  
  16. :: FAT
  17. SET FS=FAT
  18. :: Test "last accessed"time, if 00:00 for every file we may presume FAT
  19. FOR /F "TOKENS=2,3* DELIMS= " %%A IN ('DIR/A/TA/P/-P/W/-W %Drive% 2^>NUL ^| FIND ":" ^| FIND "-"') DO IF NOT "%%A"=="00:00" SET FS=
  20. DIR %Drive% >NUL 2>&1
  21. IF ERRORLEVEL 1 GOTO NotReady
  22. IF NOT "%FS%"=="" GOTO Display
  23.  
  24. :: NTFS
  25. SET FS=NTFS
  26. :: NTFS check needs a temporary file name
  27. SET TEMPFILE=
  28. FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO FOR %%B IN (0 1 2 3 4 5 6 7 8 9) DO CALL :TempFile %%A%%B %1
  29. IF "%TEMPFILE%"=="" GOTO NoTemp
  30. :: Test alternate data streams, a feature unique for NTFS
  31. (ECHO %~nx0 > %TEMPFILE%:NTFSTEST) >NUL 2>&1
  32. IF NOT EXIST %TEMPFILE% SET FS=unknown
  33. IF     EXIST %TEMPFILE% DEL %TEMPFILE%
  34.  
  35.  
  36. :Display
  37. ECHO.
  38. ECHO File system of drive %Drive% is %FS%
  39. GOTO End
  40.  
  41.  
  42. :Drive
  43. SET Drive=%~d1
  44. goto:EOF
  45.  
  46.  
  47. :TempFile
  48. IF NOT "%TEMPFILE%"=="" GOTO:EOF
  49. IF NOT EXIST %~d2\%~n0.%1$ SET TEMPFILE=%~d2\%~n0.%1$
  50. GOTO:EOF
  51.  
  52.  
  53. :NoTemp
  54. ECHO.
  55. ECHO Unable to create a temporary file for the NTFS check.
  56. ECHO Temporary file names %Drive%\%~n0.00$ through %Drive%\%~n0.99$
  57. ECHO all seem to be in use already.
  58. GOTO End
  59.  
  60.  
  61. :NotReady
  62. ECHO.
  63. ECHO Drive %Drive% is not ready
  64. GOTO End
  65.  
  66.  
  67. :Syntax
  68. ECHO.
  69. ECHO FileSys, Version 4.00 for Windows NT 4 / 2000
  70. ECHO Written by Rob van der Woude
  71. ECHO http://www.robvanderwoude.com
  72. ECHO.
  73. ECHO Usage: FILESYS [ drive ]
  74. ECHO.
  75. ECHO If no drive is specified, current drive is assumed
  76. GOTO End
  77.  
  78.  
  79. :End
  80. ENDLOCAL
  81.  

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