• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

batch file reads and lists contents in a logfile

Hi,

I need a batch file that can start in c: and go through each directory and list the file names and date and size and skip the Windows directory.  If it can find the create date and the last modify date that would be great!

Thanks,
Scott
0
jjcheap1
Asked:
jjcheap1
1 Solution
 
Shift-3Commented:
Paste the script below into a text file with a .cmd extension.  Running it will create a comma-delimited text file listing the information for every file except those under C:\WINDOWS.  It will take a very long time to run as it has to recurse through the entire file structure on the drive.
 

@echo off
setlocal enabledelayedexpansion
 
set root=c:\
set exclude=c:\windows
set report=report.csv
 
echo Path,Size (bytes),Date Created,Date Modified>"%report%"
 
for /F "tokens=*" %%G in ('dir "%root%" /A:-D /B /S /T:C ^|findstr /B /I /V /C:"%exclude%\\" 2^>NUL') do (
 for /F "tokens=1-3" %%H in ('dir "%%G" /T:C 2^>NUL') do (
  set output=%%H %%I %%J
  if "!output:~2,1!"=="/" set createdate=!output!
 )
 echo "%%G",%%~zG,!createdate!,%%~tG>>"%report%"
)

Open in new window

0
 
jjcheap1Author Commented:
Excellent Job! Works great!
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now