Write to .txt Dir/Subs|Size|LastDateMod

Microsoft Windows xp professional w/serv...
November 11, 2009 at 11:46:02
Specs: Windows XP
I ran a .bat against a network drive and returned all dir/sub dirs and it listed total counts and sizes for the dir and sub dir in bytes, as well as listed EVERY file.

Is it possible to do the following:
List the
- PATH
- FILE COUNT by DIR/SUB DIR (NO file names needed or wanted)
- SIZE TOTAL by MB
- MOST RECENT DATE/TIME OF LAST MODIFIED FILE
in a delimited (pipe, comma, tab, etc) format?

I.E.

Z:\SUBDIR1 | 100 | 536.25MB | 10/30/2009 02:11 PM
Z:\SUBDIR1\SUBSUBDIR1 | 20 | 1.45MB | 12/19/2006 02:11 PM
Z:\SUBDIR2 | 0 | 0MB | 12/19/2006 02:11 PM
Z:\SUBDIR2\SUBSUBDIR1 | 1000 | 1999MB | 03/03/2008 02:11 PM
Z:\SUBDIR2\SUBSUBDIR1\SUBSUBSUBDIR1 | 2 | 100MB | 10/28/2009 02:11 PM


etc...


See More: Write to .txt Dir/Subs|Size|LastDateMod

Report •


#1
November 11, 2009 at 14:55:19
@echo off > %TEMP%\newfile & setLocal enableDELAYedexpansion

for /f "tokens=* delims= " %%d in ('dir/s/b/ad c:\files') do (
pushd "%%d"
set N=
set Z=
set D=
for /f "tokens=* delims= " %%a in ('dir/b/od/a-d') do (
set /a N+=1
set /a Z+=%%~Za
set D=%%~Ta
)
>> %TEMP%\newfile echo !CD!, !N!, !Z!, !D!
popd
)


=====================================
Helping others achieve escape felicity

M2


Report •

#2
November 12, 2009 at 09:49:44
I keep getting "File Not Found" when executing the script. And this PRINT is over multiple rows.

I of course made the change to this line of code to reflect the correct DIR

('dir/s/b/ad c:\files')

Do I need to do the same here?

('dir/b/od/a-d c:\files' )


Report •

#3
November 12, 2009 at 14:02:22
No, that would defeat the whole purpose, just giving you a list of files in c:\files.
on mine, i got error when subdir (yahoo!) had exclamation point in it. I'm uncomfortable with burying errors as a rule, but if you can confirm that the error is spurious, (run it to screen
and see if that or something similar is kicking the error.),
go ahead. might try:
pushd "%%d" 2>nul
just to get rid of error output.

Report •

Related Solutions

#4
November 13, 2009 at 01:01:22
You do need to tailor the first FOR loop to your structure. Like Z:\ for instance.

The second FOR loop should be OK as si.


=====================================
Helping others achieve escape felicity

M2


Report •


Ask Question