Question
VBS: The Output Files of the code below sort them in the following manner: ' PURPOSE: Find files based upon their last modified date '
VBS: The Output Files of the code below sort them in the following manner:
' PURPOSE: Find files based upon their last modified date ' Parameters: ' 1 - folder path of where to search for files ' 2 - # of days older than to search for ' 3 - Recursive (Searches inside folders) or ' Non-Recursive (Searches only at the level specified) ' ' Example Input in CMD : $searchfiles.vbs "c:\users\example\desktop" 10 r '
Set CmdArg_Object = Wscript.Arguments Select Case (CmdArg_Object.Count) Case 3 sDirectoryPath = CmdArg_Object.item(0) Search_Days = CmdArg_Object.item(1) r_nr = CmdArg_Object.item(2) Case Else WScript.Echo "SearchFiles.vbs requires 3 parameters:" &_ vbcrlf & "1) Folder Path" &_ vbcrlf & "2) # Days to Search" &_ vbcrlf & "3) Recursive option (rr)" WScript.Quit End Select
Set oFSO = CreateObject("Scripting.FileSystemObject") iDaysOld=Date+(-1*Search_Days) Inp= InputBox("Please Enter Desired Location of Log File:") If Inp= "" Then Set oTF = oFSO.CreateTextFile("C:output.txt") Else Set oTF = oFSO.CreateTextFile(oFSO.BuildPath(Inp,"output.txt")) End If Set oFolder = oFSO.GetFolder(sDirectoryPath) Set oFileCollection = oFolder.Files
WScript.Echo Now & " - Beginning " & Search_Days & " day search of " & sDirectoryPath
If r_nr = "r" Then oTF.WriteLine ("Search Parameters-") &_ vbcrlf & "DirectoryPath: " & sDirectoryPath &_ vbcrlf & "Older than: " & Search_Days &" Days " &_ vbcrlf & "Recursive/Non-Recursive: " & r_nr &_ vbcrlf & "------------------ " TraverseFolders oFSO.GetFolder(sDirectoryPath)
Function TraverseFolders (FolderName) For Each SubFolder In FolderName.SubFolders For Each oFile In SubFolder.Files lastModDate = oFile.DateLastModified If (lastModDate
Else oTF.WriteLine ("Search Parameters:") &_ vbcrlf & "DirectoryPath: " & sDirectoryPath &_ vbcrlf & "Older than: " & Search_Days &" Days " &_ vbcrlf & "Recursive/Non-Recursive: " & r_nr &_ vbcrlf & "------------------------- " For Each oFile In oFileCollection lastModDate = oFile.DateLastModified If (lastModDate
If Inp="" Then WScript.Echo "Now - Finished! Results Placed in: C:output.txt" Else WScript.Echo "Now - Finished! Results Placed in: " & Inp End If
How could the size of the file be included in the search and sorted by biggest file size?
output Notepad File Edit Format View Help Search Parameters-- DirectoryPath: c:\users\EX\desktop Older than: 10 Recursive/Non-Recursive : r 7/22/2016 6:55:16 PM C:\Users\EXDesktop\LED FAN\LED Fan Editor\LedFan.exe 7/22/2016 6:55:17 PM C:\Users\EXNDesktop\LED FANLED Fan Editor\SkinHu.dll 7/22/2016 6:55:17 PM C: \Users\EXDesktop\LED FANNLED Fan Editor\ LIB\LedFan. Ini 7/22/2016 6:55:17 PM C: \Users\EXDesktop\LED FAN\LED Fan Editor LIB\LedFanv1 7/22/2016 6:55:17 PM C: \Users\EXDesktop\LED FANLED Fan Editor\LIBShe.d1l 7/22/2016 6:55:17 PM C:\Users\EXYDesktop\LED FANLED Fan Editor\LIBskin. she 7/22/2016 6:55:17 PM C:\Users\EX\Desktop\LED FANALED Fan Editor\18\the_11ASCI.bin 7/22/2016 6:55:17 PM C:\Users\EXNDesktop\LED FAN\LED Fan Editor\LIB\the_11ASCIIX.bin 7/22/2016 6:55:17 PM C:\Users\EXNDesktop\LED FAN\LED Fan Editor\LIB\the_11FH.bin 7/22/2016 6:55:17 PM C:\Users\EX\Desktop\LED FAN\LED Fan Editor\LIB\the-16ASCI.bin 7/22/2016 6:55:17 PM C:\Users\EXDesktop\LED FAN\LED Fan Editor\LIB\the 16FH.bin 7/22/2016 6:55:17 PM C: \Users\EXDesktop\LED FANLED Fan Editor\LIBNTHE_7ASCII.bin /22/2016 6:55:17 PM C: \Users\EXDesktop\LED FANLED Fan Editor\LIB\UserZK11.fnt 7/22/2016 6:55:18 PM C:\Users\EX\Desktop\LED FAN\LED Fan Editor\18\UserZK16.fnt 7/22/2016 6:55:17 PM C:\Users\EX\Desktop\LED FAN\LED Fan Editor\LIBWxkUSB . dll output Notepad File Edit Format View Help Search Parameters-- DirectoryPath: c:\users\EX\desktop Older than: 10 Recursive/Non-Recursive : r 7/22/2016 6:55:16 PM C:\Users\EXDesktop\LED FAN\LED Fan Editor\LedFan.exe 7/22/2016 6:55:17 PM C:\Users\EXNDesktop\LED FANLED Fan Editor\SkinHu.dll 7/22/2016 6:55:17 PM C: \Users\EXDesktop\LED FANNLED Fan Editor\ LIB\LedFan. Ini 7/22/2016 6:55:17 PM C: \Users\EXDesktop\LED FAN\LED Fan Editor LIB\LedFanv1 7/22/2016 6:55:17 PM C: \Users\EXDesktop\LED FANLED Fan Editor\LIBShe.d1l 7/22/2016 6:55:17 PM C:\Users\EXYDesktop\LED FANLED Fan Editor\LIBskin. she 7/22/2016 6:55:17 PM C:\Users\EX\Desktop\LED FANALED Fan Editor\18\the_11ASCI.bin 7/22/2016 6:55:17 PM C:\Users\EXNDesktop\LED FAN\LED Fan Editor\LIB\the_11ASCIIX.bin 7/22/2016 6:55:17 PM C:\Users\EXNDesktop\LED FAN\LED Fan Editor\LIB\the_11FH.bin 7/22/2016 6:55:17 PM C:\Users\EX\Desktop\LED FAN\LED Fan Editor\LIB\the-16ASCI.bin 7/22/2016 6:55:17 PM C:\Users\EXDesktop\LED FAN\LED Fan Editor\LIB\the 16FH.bin 7/22/2016 6:55:17 PM C: \Users\EXDesktop\LED FANLED Fan Editor\LIBNTHE_7ASCII.bin /22/2016 6:55:17 PM C: \Users\EXDesktop\LED FANLED Fan Editor\LIB\UserZK11.fnt 7/22/2016 6:55:18 PM C:\Users\EX\Desktop\LED FAN\LED Fan Editor\18\UserZK16.fnt 7/22/2016 6:55:17 PM C:\Users\EX\Desktop\LED FAN\LED Fan Editor\LIBWxkUSB . dllStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started