Yogesh Vedpathak

Yogesh Vedpathak

  • 675
  • 1.4k
  • 192k

Get Files Based On Datemodfied (yesteday)using Batch Script

Jun 4 2018 4:47 AM
In My Folder there are a lot of files are stored , i want get only yesterday file names into excel sheet based on current date time ...so i can see all files names which are modified yesterday
 
using batch script
 
I tried hard but not getting Excpected output
 
Current Status: its show me all files name into excel sheet
 
Requirement:- Need to show yesteday files name into excel sheet
 
here is my code ...... 
  1. @echo off  
  2. setlocal  
  3. rem Define folder to scan, and output file for CSV results  
  4. set BaseDir=E:\X\  
  5. set OutputFile=Archive.csv  
  6. (  
  7. rem Write column headers to output file  
  8. echo "Doc Name"," ","File Type","Modified Date","File Path"  
  9. rem Process all files in all folders under base folder  
  10. for /f "tokens=*" %%I in ('dir /s/b/a-d "%BaseDir%"'do (  
  11. rem Write file data to output file  
  12. echo "%%~nI","","%%~xI",%%~tI,"%%~dpI"  
  13. )  
  14. )> "%OutputFile%"  
  15. rem Open output CSV file in Excel for analysis  
  16. start excel "%OutputFile%"  
  17. rem Define folder to scan, and output file for CSV results  
  18. set BaseDir=E:\V\  
  19. set OutputFile=XBDArchive.csv  
  20. (  
  21. rem Write column headers to output file  
  22. echo "Doc Name"," ","File Type","Modified Date","File Path"  
  23. rem Process all files in all folders under base folder  
  24. for /f "tokens=*" %%I in ('dir /s/b/a-d "%BaseDir%"'do (  
  25. rem Write file data to output file  
  26. echo "%%~nI","","%%~xI",%%~tI,"%%~dpI"  
  27. )  
  28. )> "%OutputFile%"  
  29. rem Open output CSV file in Excel for analysis  
  30. start excel "%OutputFile%"  
  31. start "" /wait cmd /c "echo Opeartion Sucessful done !&echo(&pause"