[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 804
  • Last Modified:

How to list files in a folder - find all files modified on a single date AND owned by FRED

Does anyone know of a tool, ideally command line that will list files in a folder and subfolders that are modified on 1st April 2014, and owner is FRED.

Command line tool would be useful because I need results in a txt or CSV file

Many thanks for help
String,
0
TreadStone_IT
Asked:
TreadStone_IT
1 Solution
 
MacroShadowCommented:
Try running this VBScript, it will create a tab delimited text file showing different file attributes:
Dim StrFolder
StrFolder = "C:\Users\MacroShadow\Test\" ' Doesn't care if UNC has terminating backslash or not
GetFileAttributes (StrFolder)

Private Sub GetFileAttributes(StrFolder)
    Dim objShell, objFolder, objFSO, strFileName, objFile, strDisplayText, i
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.CreateTextFile("C:\Users\MacroShadow\Test\output.txt", True)
    Set objShell = CreateObject ("Shell.Application")
    Set objFolder = objShell.Namespace(StrFolder)
    Dim arrHeaders(13)
    For i = 0 To 13
        arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
    Next
    For Each strFileName In objFolder.Items
        strDisplayText = ""
        If objFolder.GetDetailsOf(strFileName, 3) = #01/04/2014# And objFolder.GetDetailsOf(strFileName, 10)="Fred" Then
	        ' Comment out any attributes you don't want
	        strDisplayText = arrHeaders(0) & ": " & objFolder.GetDetailsOf(strFileName, 0)                                          'File Name
	        strDisplayText = strDisplayText & vbTab & arrHeaders(1) & ": " & objFolder.GetDetailsOf(strFileName, 1)     'File Size
	        strDisplayText = strDisplayText & vbTab & arrHeaders(2) & ": " & objFolder.GetDetailsOf(strFileName, 2)     'Item Type
	        strDisplayText = strDisplayText & vbTab & arrHeaders(3) & ": " & objFolder.GetDetailsOf(strFileName, 3)     'Date Modified
	        strDisplayText = strDisplayText & vbTab & arrHeaders(4) & ": " & objFolder.GetDetailsOf(strFileName, 4)     'Date Created
	        strDisplayText = strDisplayText & vbTab & arrHeaders(5) & ": " & objFolder.GetDetailsOf(strFileName, 5)     'Date Accessed
	        strDisplayText = strDisplayText & vbTab & arrHeaders(6) & ": " & objFolder.GetDetailsOf(strFileName, 6)     'Attributes
	        strDisplayText = strDisplayText & vbTab & arrHeaders(7) & ": " & objFolder.GetDetailsOf(strFileName, 7)     'Offline Status
	        strDisplayText = strDisplayText & vbTab & arrHeaders(8) & ": " & objFolder.GetDetailsOf(strFileName, 8)     'Offline Availability
	        strDisplayText = strDisplayText & vbTab & arrHeaders(9) & ": " & objFolder.GetDetailsOf(strFileName, 9)     'Perceived type
	        strDisplayText = strDisplayText & vbTab & arrHeaders(10) & ": " & objFolder.GetDetailsOf(strFileName, 10)  'Owner
	        strDisplayText = strDisplayText & vbTab & arrHeaders(11) & ": " & objFolder.GetDetailsOf(strFileName, 11)  'Kind
	        strDisplayText = strDisplayText & vbTab & arrHeaders(12) & ": " & objFolder.GetDetailsOf(strFileName, 12)  'Date Taken
	        strDisplayText = strDisplayText & vbTab & arrHeaders(13) & ": " & objFolder.GetDetailsOf(strFileName, 13)  'Contributing Artists
	        objFile.WriteLine strDisplayText
        End if
    Next
End Sub

Open in new window


Don't forget to change the paths on lines 2 and 8 to reflect your details.
0
 
ste5anSenior DeveloperCommented:
There are no owners in MS DOS..

Using the Cmd Shell: FORFILES /D to get the files and DIR /Q or CACLS to get the owner.
0
 
Bill PrewCommented:
Have you tried DIR /Q to see if it shows the owner info you are looking for?  If these are files on a network share it may.  If it does, then the rest could be done in a DOS bat script.

~bp
0
 
TreadStone_ITAuthor Commented:
Thanks everyone who read\responded to my question. The DIR /q gave me the info I needed but not in a format I could easily use.
The VB script gave me a csv file that I could manipulate.
Many thanks again
Have a great weekend
String
0
 
TreadStone_ITAuthor Commented:
Thanks a bunch!!!
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now