Skip navigation

JSI Tip 8640. How can I schedule a report of files created or modified yesterday?


Using DatePorM.bat, I have scripted FilesChangedYesterday.bat to generate a .txt file of file names that were created or modified yesterday.

The syntax for using FilesChangedYesterday.bat is:

FilesChangedYesterday Drive: ReportFolder \[/A\]

Where Drive: is the drive letter (or folder path) you want enumerated, ReportFolder is the folder path that will contain a YYYYMMDD.txt file with the files that were changed yesterday, and /A is an optional parameter that will only find yesterday's files if their archive bit is set.

NOTE: FilesChangedYesterday.bat assumes a MM/DD/YYYY date format, but you can easily change that by altering the set report="%report%\%yesterday:~6,4%%yesterday:~0,2%%yesterday:~3,2%.txt" line.

FilesChangedYesterday.bat contains:

@echo off
If \{%2\}

\{\} @echo Syntax: FilesChangedYesterday Drive: ReportFolder \[/A\]&goto :EOF if not exist %1 @echo FilesChangedYesterday %1 not found.&goto :EOF if not exist %2 @echo FilesChangedYesterday %2 not found.&goto :EOF setlocal set drv=%1 set report=%~2 call DatePorM -1 Yesterday set report="%report%\%yesterday:~6,4%%yesterday:~0,2%%yesterday:~3,2%.txt" set report=%report:\\=\% set dirc=dir %drv% /b /s /a-d if /i \{%3\}

\{/A\} set dirc=%dirc% /aa for /f "Tokens=*" %%a in ('%dirc%') do ( for /f "Tokens=1" %%b in ('@echo "%%~Ta"') do ( if "%%~b" EQU "%Yesterday%" @echo %%a>>%report% ) ) endlocal



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish