Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting File Info using GetDetailsOf

3,570 views
Skip to first unread message

scott

unread,
Aug 6, 2006, 6:20:28 PM8/6/06
to
In CODE 2 I've got a working example from MS showing the properties of any
files that reside in c:\temp folder.

However, I'm failing miserably in CODE 1 Vbelow when simply trying to
display the date modified property of a single file. My MsgBox displays the
text "Date Modified" instead of the ctual datetime value of the property.
What am I doing wrong?

CODE 1 ***********

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\temp")
sFolderTargetDate = objFolder.GetDetailsOf("test.exe", 3)

MsgBox "date stamp: " & sFolderTargetDate


CODE 2 *****************

Dim arrHeaders(35)
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\temp")
For i = 0 to 6
arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
Next
For Each strFileName in objFolder.Items
For i = 0 to 6
MsgBox i & vbtab & arrHeaders(i) _
& ": " & objFolder.GetDetailsOf(strFileName, i)
Next
Next

Steven Burn

unread,
Aug 6, 2006, 7:45:11 PM8/6/06
to
Why not just use FSO?

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

"scott" <sba...@mileslumber.com> wrote in message
news:ONcHvYau...@TK2MSFTNGP03.phx.gbl...

Walter Zackery

unread,
Aug 7, 2006, 3:17:31 AM8/7/06
to
"scott" <sba...@mileslumber.com> wrote in message
news:ONcHvYau...@TK2MSFTNGP03.phx.gbl...
: In CODE 2 I've got a working example from MS showing the properties of any

: files that reside in c:\temp folder.
:
: However, I'm failing miserably in CODE 1 Vbelow when simply trying to
: display the date modified property of a single file. My MsgBox displays
the
: text "Date Modified" instead of the ctual datetime value of the property.
: What am I doing wrong?
:
: CODE 1 ***********
:
: Set objShell = CreateObject("Shell.Application")
: Set objFolder = objShell.Namespace("C:\temp")
: sFolderTargetDate = objFolder.GetDetailsOf("test.exe", 3)
:
: MsgBox "date stamp: " & sFolderTargetDate
:


The GetDetailsOf method requires a FolderItem object, not a string, as its
first parameter.

sFolderTargetDate = objFolder.GetDetailsOf(objFolder.ParseName("test.exe"),
3)


scott

unread,
Aug 7, 2006, 9:06:06 AM8/7/06
to
FSO actions make Norton give virus warnings.


"Steven Burn" <some...@in-time.invalid> wrote in message
news:eNLRkIbu...@TK2MSFTNGP02.phx.gbl...

OldDog

unread,
Aug 7, 2006, 12:40:44 PM8/7/06
to
This pulls all the Access files in c:\scripts and gives you the first 9
details (Tab delimited);

Dim arrHeaders(35)


Set objShell = CreateObject("Shell.Application")

Set objFolder = objShell.Namespace("C:\Scripts")
WScript.Echo "Name" & vbTab & "Size" & vbTab & "Type" & vbTab & "Date
Modified" & vbTab & "Date Created" & vbTab & "Date Accessed" & vbTab &
"Attributes" & vbTab &_
vbTab & "Status" & vbTab & "Owner" & vbTab & "Author"

For Each strFileName in objFolder.Items

If objFolder.GetDetailsOf(strFileName, 2) = "Microsoft Office Access
Application" Then
WScript.Echo objFolder.GetDetailsOf(strFileName, 0) & _
vbTab & objFolder.GetDetailsOf(strFileName, 1) & _
vbTab & objFolder.GetDetailsOf(strFileName, 2) & _
vbTab & objFolder.GetDetailsOf(strFileName, 3) & _
vbTab & objFolder.GetDetailsOf(strFileName, 4) & _
vbTab & objFolder.GetDetailsOf(strFileName, 5) & _
vbTab & objFolder.GetDetailsOf(strFileName, 6) & _
vbTab & objFolder.GetDetailsOf(strFileName, 7) & _
vbTab & objFolder.GetDetailsOf(strFileName, 8) & _
vbTab & objFolder.GetDetailsOf(strFileName, 9)
End If
Next

Or, if you are feeling frisky, you can try PowerShell;

A specific File Type
get-childitem . *.mdb -rec -ea SilentlyContinue | select Name,
DirectoryName, Extension, LastWriteTime, LastAccessTime, CreationTime,
@{e={(Get-Acl $_.PSpath).Owner};n='Owner'} | export-csv
C:\Temp\FileType.csv

A specific Sub Directory
get-childitem P:\Agncrel\BackupOfDatabase -rec -ea SilentlyContinue |
select Name, DirectoryName, Extension, LastWriteTime, LastAccessTime,
CreationTime, Length, {(Get-Acl $_.PSpath).Owner} | export-csv
C:\Temp\SubDir.csv

>From a Txt File of File Names
Get-Content "C:\Scripts\foo.txt" | Get-ChildItem -ea SilentlyContinue |
Select-Object Name, DirectoryName, Extension, LastWriteTime,
LastAccessTime, CreationTime, Length, {(Get-Acl $_.PSpath).Owner} |
export-csv C:\Temp\Mtgsmnmi015.csv

A whole directory
Get-ChildItem . -Recurse -ea SilentlyContinue | Select-Object Name,
DirectoryName, Extension, LastWriteTime, LastAccessTime, CreationTime,
@{e={(get-acl $_.PSath).owner};n='Owner'} | export-csv
C:\Temp\WholeDir.csv

Malph

unread,
Oct 12, 2006, 5:10:02 PM10/12/06
to
This works (ASP)... retrieving all files from the images folder where this
script is run. Main thing is not to getdetails of a filename string, but of
an item within the object containing the namespace of the path.

rootpath = Server.MapPath("./")
path = Server.MapPath("images/")

dim fs, folder
Set objShell = CreateObject ("Shell.Application")
Set objFolder = objShell.Namespace(path)
Dim arrHeaders(39)
For i = 0 to 39
arrHeaders(i) = objFolder.GetDetailsOf (objFolder.Items, i)


Next
For Each strFileName in objFolder.Items

For i = 0 to 39
'If i <> 9 then
Response.Write(arrHeaders(i) & ": " & objFolder.GetDetailsOf
(strFileName, i) ) & "<br />" & vbCrLf
'End If
Next
Next
%>

0 new messages