Read file attributes and store in a table ????????

D

DavPet

Can some one get me started on how I can read the files in a folder and
store the file name, size and modified date in a table? Can I also read the
permissions?
 
J

John Nurick

Can some one get me started on how I can read the files in a folder and
store the file name, size and modified date in a table? Can I also read the
permissions?

There are various ways of doing this; which to choose depends on your
programming skills and just what's required. In general I don't think
it's worth doing except for folders that are archived offline: if the
stuff is online it's liable to change and it's easier to get the
information from the folder when needed than it is to keep the table up
to date.

One way to get everything, including permissions, is to download the
Windows port of Unix utilities from http://unxutils.sourceforge.net and
use 'ls', the Unix equivalent of DIR. This command
ls -o "D:\folder" > "D:\other folder\files.txt"
creates a fixed-width text file listing all the files and folders in the
D:\Folder, which can be imported into an Access table. You'll need to
check the documentation for 'ls' to work out what the various fields in
the list mean.

Alternatively, you can use good old VBA. Repeated calls to Dir() will
give you each filename in the folder, while FileLen(), FileDateTime()
and GetAttr() will get you most of the rest. It won't, however, get you
the NTFS permissions. For that, I think you may need to use the WMI
object library; see e.g.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/anch_wmi.asp
 
D

DavPet

John Nurick said:
There are various ways of doing this; which to choose depends on your
programming skills and just what's required. In general I don't think
it's worth doing except for folders that are archived offline: if the
stuff is online it's liable to change and it's easier to get the
information from the folder when needed than it is to keep the table up
to date.

One way to get everything, including permissions, is to download the
Windows port of Unix utilities from http://unxutils.sourceforge.net and
use 'ls', the Unix equivalent of DIR. This command
ls -o "D:\folder" > "D:\other folder\files.txt"
creates a fixed-width text file listing all the files and folders in the
D:\Folder, which can be imported into an Access table. You'll need to
check the documentation for 'ls' to work out what the various fields in
the list mean.

Alternatively, you can use good old VBA. Repeated calls to Dir() will
give you each filename in the folder, while FileLen(), FileDateTime()
and GetAttr() will get you most of the rest. It won't, however, get you
the NTFS permissions. For that, I think you may need to use the WMI
object library; see e.g.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/anch_wmi.asp


Thank you for the response.
I need to document the folder permissions for our QA program.
Looks like I'll be studying up on WMI.
 
J

John Nurick

Thank you for the response.
I need to document the folder permissions for our QA program.
Looks like I'll be studying up on WMI.

If you need a full report on permissions I think you'll need to iterate
through the ACLs. You may be able to borrow or modifiy code from
XCACLS.VBS (http://support.microsoft.com/?id=825751). This is a massive
console-oriented VBSCript that uses WMI/WBEM to list or control
permissions on files or folders.
 
Top