Hi all - was given what I thought was a simple task but it's done my head in trying it with vbs/powershell/commandprompt etc. Simply list all files in a folder and its subfolders that are older than 2005, in csv format for excel.
A remarkably good way seemed to be a commandline that only took 10m to run on the large network path of 320k files/330g
Only downside is it doesn't show the file owners which they wanted.
So I tried various VBS and though I've got a few scripts (some list all the information but run for hours) and the shortest I have is the following which isn't recursive and doesn't show the owner on half the files for no reason (some show fine)
So I tried dabbling with powershell which I've never really used before and got this
which works well but doesn't have owner information and shows the full path whereas just the subpath would be better.
I don't know how much memory it would take up either or how long it'd take to run on 320k files weighing 330g on a network drive.
I'm sure there are simple fixes for any of these?
_________________________________
Leozack
A remarkably good way seemed to be a commandline that only took 10m to run on the large network path of 320k files/330g
Code:
forfiles /S /D -01/01/2005 /C "cmd /c echo @fdate,@relpath" > d:\testoutput.txt
So I tried various VBS and though I've got a few scripts (some list all the information but run for hours) and the shortest I have is the following which isn't recursive and doesn't show the owner on half the files for no reason (some show fine)
Code:
Dim strfolder, Objshell2
Set objshell2 = CreateObject("Wscript.shell")
' Doesn't care if UNC has terminating backslash or not
strFolder = "D:\Data"
GetFileAttributes(strFolder)
Private Sub GetFileAttributes (StrFolder)
Dim objShell, objFolder, objFSO, strFileName, strDisplayText, i
Set objShell = CreateObject ("Shell.Application")
Set objFolder = objShell.Namespace (strFolder)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set f1 = objFSO.CreateTextFile(objshell2.ExpandEnvironmentStrings("%TEMP%\testfile.txt"), True)
Dim arrHeaders(13)
For i = 0 to 13
arrHeaders(i) = objFolder.GetDetailsOf (objFolder.Items, i)
Next
For Each strFileName in objFolder.Items
strDisplayText = ""
If (Mid(objFolder.GetDetailsOf (strFileName, 3),7,4) < 2012) Then
strDisplayText = objFolder.GetDetailsOf (strFileName, 0) 'File Name
strDisplayText = strDisplayText & "," & objFolder.GetDetailsOf (strFileName, 3) 'Date Modified
strDisplayText = strDisplayText & "," & objFolder.GetDetailsOf (strFileName, 10) 'Owner
f1.Writeline(strDisplayText)
End If
Next
End Sub
'Display Text file on screen
objshell2.run "%TEMP%\testfile.txt"
So I tried dabbling with powershell which I've never really used before and got this
Code:
GCI -recurse D:\Data | where {$_.lastwritetime -lt "1/1/2005"} | select LastWritetimeUTC, FullName | Export-Csv d:\testfiles.txt -notype
I don't know how much memory it would take up either or how long it'd take to run on 320k files weighing 330g on a network drive.
I'm sure there are simple fixes for any of these?
_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);