Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for modified.bat

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

  1. @ECHO OFF
  2. REM * MODIFIED.BAT
  3. REM * Check if specified file was created or modified today
  4. REM * Written by Rob van der Woude
  5.  
  6. REM * Needs write access to current directory; or add fully qualified
  7. REM * path to files CURRENT.BAT and its language dependent versions,
  8. REM * and make sure its path is specified in the PATH variable.
  9.  
  10. REM * File name should be specified
  11. IF "%1"=="" GOTO Syntax
  12. IF NOT EXIST %1 GOTO Syntax
  13.  
  14. REM * Send DIR output for specified file to primary temporary
  15. REM * batch file to get the file's creation or modification date
  16. DIR %1 | FIND /I "%1" > %TEMP%.\~ISMODIF.TMP
  17. ECHO.>> %TEMP%.\~ISMODIF.TMP
  18. TYPE %TEMP%.\~ISMODIF.TMP | TIME | FIND /I "%1" > %TEMP%.\~ISMODIF.BAT
  19. REM * Create secondary temporary batch files to be called by primary
  20. ECHO SET CHKDATE=%%4>ENTER.BAT
  21. REM * For Dutch DOS versions
  22. ECHO SET CHKDATE=%%5>VOER.BAT
  23. ECHO SET CHKDATE=%%6>TYP.BAT
  24. CALL %TEMP%.\~ISMODIF.BAT
  25.  
  26. REM * Send DIR output for temporary batch file to itself to get today's date
  27. DIR %TEMP%.\~ISMODIF.BAT | FIND /I "~ISMODIF.BAT" > %TEMP%.\~ISMODIF.TMP
  28. ECHO.>> %TEMP%.\~ISMODIF.TMP
  29. TYPE  %TEMP%.\~ISMODIF.TMP | TIME | FIND /I "~ISMODIF.BAT" > %TEMP%.\~ISMODIF.BAT
  30. REM * Create secondary temporary batch files to be called by primary
  31. ECHO SET NOWDATE=%%4>ENTER.BAT
  32. REM * For Dutch DOS versions
  33. ECHO SET NOWDATE=%%5>VOER.BAT
  34. ECHO SET NOWDATE=%%6>TYP.BAT
  35. CALL %TEMP%.\~ISMODIF.BAT
  36.  
  37. REM * Compare dates and display result
  38. IF "%NOWDATE%"=="%CHKDATE%" ECHO %1 was created or modified today (%NOWDATE%)
  39.  
  40. REM * Clean up the mess
  41. DEL %TEMP%.\~ISMODIF.BAT
  42. DEL %TEMP%.\~ISMODIF.TMP
  43. DEL ENTER.BAT
  44. DEL VOER.BAT
  45. DEL TYP.BAT
  46. SET CHKDATE=
  47. SET NOWDATE=
  48. GOTO End
  49.  
  50. :Syntax
  51. ECHO MODIFIED.BAT
  52. ECHO Check if specified file was created or modified today
  53. ECHO Written by Rob van der Woude
  54. ECHO.
  55. ECHO.
  56. ECHO Usage:  %0  filename
  57.  
  58. :End
  59.  

page last uploaded: 2017-08-21, 14:26