Sign in with
Sign up | Sign in
Your question

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

Last response: in Windows XP
Share
January 25, 2012 10:00:29 PM

I'm looking for a dir command that displays each file with complete path, with file sizes. "dir /s /b" doesn't show sizes.
January 26, 2012 11:26:58 AM

The /b (bare) tells it not to show file sizes. Don't use the /b switch. there is no switch to have it show the full path. You will need to find a utility other than "dir".
m
0
l
January 27, 2012 3:46:02 AM

Hawkeye22 said:
The /b (bare) tells it not to show file sizes. Don't use the /b switch. there is no switch to have it show the full path. You will need to find a utility other than "dir".


Hi Hawkeye,
Strangely enough, the /s /b combination does give full paths; it just doesn't give file sizes. Thanks for replying. Chas
m
0
l
Related resources
January 27, 2012 10:45:34 AM

That's weird. The help says /b is bare and when I do a dir /s/b on my xp computer all I get is the full path/filename. I'm not sure if ls comes standard on xp. Try this:

ls -R -s

That's a capital R and lower case s.
m
0
l
January 27, 2012 12:39:15 PM

Hawkeye22 said:
That's weird. The help says /b is bare and when I do a dir /s/b on my xp computer all I get is the full path/filename. I'm not sure if ls comes standard on xp. Try this:

ls -R -s

That's a capital R and lower case s.



Thanks - I'll try this as soon as I figure out how to make Unix commands work.
m
0
l
January 27, 2012 12:56:50 PM

Yeah, it works on my xp machine, but I can't remember if it came with the system or if I installed some developer tool that added this in.
m
0
l
February 9, 2012 8:47:06 PM

charles gentry said:
I'm looking for a dir command that displays each file with complete path, with file sizes. "dir /s /b" doesn't show sizes.




@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

m
0
l
February 10, 2012 12:26:30 PM

Thanks LAMS. I will try it. Charles
m
0
l
February 10, 2012 9:32:02 PM

charles gentry said:
Thanks LAMS. I will try it. Charles


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
m
0
l
!