Dir commandthat displays each file with complete path, with file sizes

charles gentry

Distinguished
Jan 25, 2012
5
0
18,510


Hi Hawkeye,
Strangely enough, the /s /b combination does give full paths; it just doesn't give file sizes. Thanks for replying. Chas
 

charles gentry

Distinguished
Jan 25, 2012
5
0
18,510



Thanks - I'll try this as soon as I figure out how to make Unix commands work.
 

LAMS_73

Distinguished
Feb 9, 2012
2
0
18,510




@REM =======================
@REM newdir.cmd
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION

FOR /R . %F in (*) DO (
set y=0000000000%%~zF
echo %%~tF !y:~-10! %%~fF )
@echo on
@REM =======================

run command: newdir
or to sort by size
run command: newdir | sort /+21

obviously can add arguments to make it better

set arg1=%1 @rem expecting . or directory eg c:\tmp\
set arg2=%2 @rem expecting wildcard * or *.tmp or *.bak

FOR /R %arg1% %%F in (%arg2%) DO ( ....

~?F e.g. ~zF values examples are:
~a attributes,
~d drive ,
~f full filename,
~n name of file without ext,
~p = folder(s),
~s= short filename,
~t = datetime stamp,
~x=ext,
~z = size in bytes

Cheers
LAMS

 

LAMS_73

Distinguished
Feb 9, 2012
2
0
18,510


oops stuff up it should be %%F instead of %F in the text file that is saved as
newdir.cmd

@REM =======================
@REM newdir.cmd
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION

FOR /R . %%F in (*) DO (
set y=0000000000%%~zF
echo %%~tF !y:~-10! %%~fF )
@echo on
@REM =======================

run command: newdir
or to sort by size
run command: newdir | sort /+21