How to display seconds with the DIR command?
Moderators: Hacker, petermad, Stefan2, white
How to display seconds with the DIR command?
I use DIR > file.txt to get a list of files, including time stamps. Is there under Windows XP a way to create a txt-file with the seconds also displayed in the time stamps of the file list?
regards
Peter
regards
Peter
TC 10.xx / #266191
Win 10 x64
Win 10 x64
Yeah - that looks remarkable. But what's about displaying recursive subdirs?Jack! wrote:Here's an alternative way. Copy the file path (example c:\windows) in to the address bar of Firefox or Chrome et voilà, you'll see a file list including a time stamp with seconds.
Peter
TC 10.xx / #266191
Win 10 x64
Win 10 x64
If you can't use any other software, then the answer is built-in Windows scripting.
Try something like this, save it to mydir.vbs:
Usage examples:
If you don't like the format, it's easy to change.
Try something like this, save it to mydir.vbs:
Code: Select all
Set objFSO = CreateObject("Scripting.FileSystemObject")
If WScript.Arguments.Count = 0 Then
strFolder = objFSO.GetAbsolutePathName(".")
isRec = False
Else
If WScript.Arguments.Count = 1 Then
If WScript.Arguments(0) = "/rec" Then
strFolder = objFSO.GetAbsolutePathName(".")
isRec = True
Else
strFolder = objFSO.GetAbsolutePathName(WScript.Arguments(0))
isRec = False
End If
Else
strFolder = objFSO.GetAbsolutePathName(WScript.Arguments(0))
If WScript.Arguments(1) = "/rec" Then
isRec = True
Else
isRec = False
End If
End If
End If
GetFiles strFolder
Function GetFiles(byval strDirectory)
WScript.StdOut.WriteLine "Listing of " & strDirectory
Set objFolder = objFSO.GetFolder(strDirectory)
For Each objFile In objFolder.Files
WriteItemLine objFile, False
Next
If isRec Then
For Each objFolder In objFolder.SubFolders
WriteItemLine objFolder, True
GetFiles objFolder.Path
Next
End If
End Function
Function WriteItemLine(byref objFile, byval isFolder)
strLine = ""
strLine = strLine & objFile.DateLastModified & ", "
If isFolder Then
strLine = strLine & "directory, "
Else
strLine = strLine & "file, "
End If
strLine = strLine & objFile.Size & ", "
strLine = strLine & objFile.Name
WScript.StdOut.WriteLine strLine
End Function
Code: Select all
cscript //B //U mydir.vbs > current-dir.txt
cscript //B //U mydir.vbs C:\Temp > some-other-dir.txt
cscript //B //U mydir.vbs /rec > current-dir-recursive.txt
cscript //B //U mydir.vbs C:\Temp /rec > some-other-dir-recursive.txt
- Balderstrom
- Power Member
- Posts: 2148
- Joined: 2005-10-11, 10:10 UTC
Here's the most up to date one that I know of on google code UnxUtils
If installed, Add the wbin folder to Windows Path, or create a junction to it, and add that to the path.
I recommend renaming echo, find, date and type to gecho.exe, gfind.exe (etc).
All the files included:
If installed, Add the wbin folder to Windows Path, or create a junction to it, and add that to the path.
I recommend renaming echo, find, date and type to gecho.exe, gfind.exe (etc).
All the files included:
[face=trebuchetms]agrep.exe
ansi2knr.exe
basename.exe
bc.exe
bison.exe
bunzip2.exe
bzip2.exe
bzip2recover.exe
cat.exe
chgrp.exe
chmod.exe
chown.exe
cksum.exe
cmp.exe
comm.exe
compress.exe
cp.exe
csplit.exe
cut.exe
date.exe
dc.exe
dd.exe
df.exe
diff.exe
diff3.exe
dircolors.exe
dirname.exe
du.exe
echo.exe
egrep.exe
env.exe
expand.exe
expr.exe
factor.exe
fgrep.exe
find.exe
flex.exe
fmt.exe
fold.exe
fsplit.exe
gawk.exe
gclip.exe
gplay.exe
grep.exe
gsar.exe
gunzip.exe
gzip.exe
head.exe
id.exe
indent.exe
install.exe
join.exe
jwhois.exe
less.exe
lesskey.exe
libfl.a
libfl.lib
ln.exe
logname.exe
ls.exe
m4.exe
make.exe
makedepend.exe
makemsg.exe
man.exe
md5sum.exe
mkdir.exe
mkfifo.exe
mknod.exe
mv.exe
mvdir.exe
nl.exe
od.exe
paste.exe
patch.exe
pathchk.exe
pclip.exe
pr.exe
printenv.exe
printf.exe
ptx.exe
pwd.exe
recode.exe
rm.exe
rman.exe
rmdir.exe
sdiff.exe
sed.exe
seq.exe
sha1sum.exe
shar.exe
sleep.exe
sort.exe
split.exe
stego.exe
su.exe
sum.exe
sync.exe
tac.exe
tail.exe
tar.exe
tee.exe
test.exe
touch.exe
tr.exe
tsort.exe
type.exe
uname.exe
unexpand.exe
uniq.exe
unrar.exe
unshar.exe
unzip.exe
uudecode.exe
uuencode.exe
wc.exe
wget.exe
wget.hlp
which.exe
whoami.exe
xargs.exe
yes.exe
zcat.exe
zip.exe
zsh.exe[/face]
[OT]
I will recommend MSYS base system(~7 MB), the UnxUtils are from 1998 to 2003.
MSYS installer : http://downloads.sourceforge.net/project/mingw/MSYS/BaseSystem/msys-1.0.11/MSYS-1.0.11.exe?use_mirror=sunet
[OT]
I will recommend MSYS base system(~7 MB), the UnxUtils are from 1998 to 2003.
MSYS installer : http://downloads.sourceforge.net/project/mingw/MSYS/BaseSystem/msys-1.0.11/MSYS-1.0.11.exe?use_mirror=sunet
[OT]
Last edited by dott on 2010-06-16, 06:37 UTC, edited 1 time in total.
Probablemente no
Re:Very bad news - see 3
I gave up the parameter //B because it hides errors like "Permission Denied" when executing objFile.Size
Workaround - I run the script command using "Run as Administrator" window
I tried some error handling procedures without success
1. Try Catch is not yet implemented in cscript (version 5.812) even it is advertised by Microsoft (but maybe it works work only inside the MS Studio and was not implemented in cscript, yet)
2. the old VBA exception method "on Error Resume Next" is not working for Permission Denied
I could not catch the error and the effect is that it loses all the files after the error
In my case, the first directory was the known "Recycle Bin" so no other subdirectory was included in the listing as the program crashed early
3. Very bad news - the VBA software crashed for path length over 256 characters
Code: Select all
objFile.Size
3.2 Even if you execute
Code: Select all
On Error Resume Next
Code: Select all
objFolder.SubFolders
I have to write my own program in a different Programming Language
Thank you for your solution - it is fast even for my million files on many HDD (not as fast as DIR but I found too many problems in DIR (seconds, date format change between computers and time zone changes ....))
At least in your solution, you can develop something independent of computer and time zone

Re: How to display seconds with the DIR command?
An alternative in CMD:
Run secondtime.cmd "c:\some folder\" to get similar output like below. Parse the results ffurther from there.
Make sure the foldername ends with a "\" (or change the code).
It should be fast.
Personally, I would use PowerShell for this.
secondtime.cmd
Run secondtime.cmd "c:\some folder\" to get similar output like below. Parse the results ffurther from there.
Make sure the foldername ends with a "\" (or change the code).
It should be fast.
Personally, I would use PowerShell for this.
Code: Select all
C:\Temp>secondtime.cmd "c:\Test\emed64_18.7.2_portable\"
Extension FileName FileSize LastModified Path
exe eeadmin 213752 20190327223308.000000+060 \test\emed64_18.7.2_portable\
ini eecommon 22606 20190624085751.813939+120 \test\emed64_18.7.2_portable\
ini eeconfig 776120 20190518015958.877174+120 \test\emed64_18.7.2_portable\
ini eelm 2 20190414002324.962960+120 \test\emed64_18.7.2_portable\
dll eemacro 1080056 20190327223322.000000+060 \test\emed64_18.7.2_portable\
tlb eemacro 82996 20190327223220.000000+060 \test\emed64_18.7.2_portable\
ini eePlugins 170 20190518014633.361255+120 \test\emed64_18.7.2_portable\
ini eeuseini 0 20190327224112.137600+060 \test\emed64_18.7.2_portable\
dll emedcfd 2575608 20190327223306.000000+060 \test\emed64_18.7.2_portable\
dll emedcfg 865528 20190327223312.000000+060 \test\emed64_18.7.2_portable\
dll emeddlgs 975096 20190327223420.000000+060 \test\emed64_18.7.2_portable\
dll emeddlgt 682232 20190327223256.000000+060 \test\emed64_18.7.2_portable\
exe emedhtml 138488 20190327223218.000000+060 \test\emed64_18.7.2_portable\
exe emeditor 22645496 20190327223938.000000+060 \test\emed64_18.7.2_portable\
secondtime.cmd
Code: Select all
@echo off & setlocal
set "THISPATH=%~pnx1"
set "WHERE=Drive='%~d1' AND Path='%THISPATH:\=\\%'"
wmic.exe datafile WHERE "%WHERE%" get Path,FileName,Extension, FileSize,LastModified