{"id":5,"date":"2007-09-06T23:23:21","date_gmt":"2007-09-07T04:23:21","guid":{"rendered":"http:\/\/blog.bitsofgenius.com\/?p=5"},"modified":"2011-01-26T15:13:10","modified_gmt":"2011-01-26T19:13:10","slug":"deleting-old-files","status":"publish","type":"post","link":"https:\/\/blog.bitsofgenius.com\/?p=5","title":{"rendered":"Deleting Old Files"},"content":{"rendered":"<p>I&#8217;ve had this script around for some time, and thought I would share it.  There are many utilities that will do this, but this one is designed for VBScript, and uses regular expressions for the file pattern.  This allows for almost surgical removal of files from a working folder or archive folder.  I&#8217;ve used this script for some time on several servers I work with, and it&#8217;s pretty reliable.<\/p>\n<p>You can also execute the script in the console (with CScript), and it will display a list of available parameters.  Enjoy.<\/p>\n<p>You can download the code <a href=\"\/?page_id=8\">here<\/a>.<\/p>\n<pre lang=\"vb\" line=\"1\" escaped=\"true\">\r\n' DeleteAgedFiles.vbs -- Remove files by any combination of timestamp aging, file pattern.\r\n' John J Schultz -- 12\/12\/2005 -- Public Domain.\r\n'\r\n' \/\/B is the switch recommended for production use with wscript to suppress operator messages from\r\n' the script engine (e.g. when launched from a timer).  Due to the number of WScript.Echo statements used,\r\n' Cscript is highly recommended--even when testing.\r\n\r\n' ----------------------------\r\n' Parameters\r\nDim bAggressive\r\nDim bTestRun\r\nDim bIncludeSubFolders\r\nDim bSpareRootFolder\r\nDim bRemoveEmptyFolders\r\nDim bBatchMode\r\nDim bUserConfirmationForDelete\r\nDim bIgnoreZeroLengthFiles\r\nDim nDateToCheck\r\nDim nDays\r\nDim sStartFolder\r\nDim sFilePattern\r\nDim nPreserveFileCount\r\n\r\n' ----------------------------\r\n' Global\r\nDim dCutOff\r\nDim iErr, sErr\r\n\r\n' ###################################################################################\r\n' Support Functions and Subs\r\nSub LogAnEvent (iType, sMessage)\r\n\tSet WshShell = WScript.CreateObject(&quot;WScript.Shell&quot;)\r\n\tWshShell.LogEvent iType, sMessage\r\n\tSet WshShell = Nothing\r\nEnd Sub\r\n\r\nFunction DateToAnsi (dTime)\r\n   DateToAnsi = _\r\n   Year(dTime) &amp; Right (&quot;0&quot; &amp; Month (dTime), 2) &amp; Right (&quot;0&quot; &amp; Day (dTime), 2) &amp; _\r\n   Hour(dTime) &amp; Right (&quot;0&quot; &amp; Minute (dTime), 2) &amp; Right (&quot;0&quot; &amp; Second (dTime), 2)\r\nEnd Function\r\n\r\nSub QuickSort(ByRef aKey, nLowBound, nHighBound)\r\n\t' Single dimension array only.\r\n\tDim vPivot, nLowSwap, nHighSwap, vTemp\r\n\r\n\tIf IsEmpty (nLowBound) Then\r\n\t\tnLowBound = LBound (aKey)\r\n\tEnd If\r\n\tIf IsEmpty (nHighBound) Then\r\n\t\tnHighBound = UBound (aKey)\r\n\tEnd If\r\n\r\n\t' Two items to sort\r\n\tIf nHighBound - nLowBound = 1 Then\r\n\t\tIf aKey(nLowBound) &gt; aKey(nHighBound) Then\r\n\t\t\tvTemp = aKey(nLowBound)\r\n\t\t\taKey(nLowBound) = aKey(nHighBound)\r\n\t\t\taKey(nHighBound) = vTemp\r\n\t\tEnd If\r\n\tEnd If\r\n\r\n\t' Three or more items to sort\r\n\r\n\tvPivot = aKey(int((nLowBound + nHighBound) \/ 2))\r\n\taKey(int((nLowBound + nHighBound) \/ 2)) = aKey(nLowBound)\r\n\taKey(nLowBound) = vPivot\r\n\r\n\tnLowSwap = nLowBound + 1\r\n\tnHighSwap = nHighBound\r\n\r\n\tDo\r\n\t\t' Find the right nLowSwap\r\n\t\tWhile nLowSwap &lt; nHighSwap and aKey(nLowSwap) &lt;= vPivot\r\n\t\t\tnLowSwap = nLowSwap + 1\r\n\t\tWend\r\n\t\t' Find the right nHighSwap\r\n\t\tWhile aKey(nHighSwap) &gt; vPivot\r\n\t\t\tnHighSwap = nHighSwap - 1\r\n\t\tWend\r\n\t\t' Swap values if out of sort order\r\n\t\tIf nLowSwap &lt; nHighSwap Then\r\n\t\t\tvTemp = aKey(nLowSwap)\r\n\t\t\taKey(nLowSwap) = aKey(nHighSwap)\r\n\t\t\taKey(nHighSwap) = vTemp\r\n\t\tEnd If\r\n\tLoop While nLowSwap &lt; nHighSwap\r\n\r\n\taKey(nLowBound) = aKey(nHighSwap)\r\n\taKey(nHighSwap) = vPivot\r\n\r\n\t' Recursive call\r\n\t' 2 or more items in first section\r\n\tIf nLowBound &lt; (nHighSwap - 1) Then Call QuickSort(aKey, nLowBound, nHighSwap - 1)\r\n\t' 2 or more items in second section\r\n\tIf nHighSwap + 1 &lt; nHighBound Then Call QuickSort(aKey, nHighSwap + 1, nHighBound)\r\n\r\nEnd Sub\r\n\r\nFunction FolderExists (sFolderName)\r\n\tDim oFS\r\n\r\n\tSet oFS = CreateObject(&quot;Scripting.FileSystemObject&quot;)\r\n\tFolderExists = oFS.FolderExists(sFolderName)\r\n\tset oFS = Nothing\r\nEnd Function\r\n\r\nFunction FileMatchesPattern (sFile, sPattern, bIgnoreCase)\r\n    ' Returns true if the file name matches the regular expression in sPattern.\r\n    Dim oRegEx\r\n\r\n    Set oRegEx = New RegExp\r\n    With oRegEx\r\n\t    .Pattern = sPattern\r\n\t    .IgnoreCase = bIgnoreCase\r\n\t    FileMatchesPattern = .Test (sFile)   ' Execute search.\r\n    End With\r\n    Set oRegEx = Nothing\r\nEnd Function\r\n\r\nSub RemoveFilesInFolder (sPath, bAtTop)\r\n\t' Recursive -- uses modular variables\r\n\tDim objFSO\r\n\tDim objFolder\r\n\tDim objFolders\r\n\tDim objFile\r\n\tDim objFiles\r\n\tDim objItem\r\n\tDim sFileName\r\n\tDim bPardoned\r\n\tDim sWorkPath\r\n\tDim iErr\r\n\tDim aSort\r\n\r\n\tSet objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)\r\n\tsWorkPath = sPath\r\n\tIf Right (sWorkPath, 1) &lt;&gt; &quot;\\&quot; Then sWorkPath = sWorkPath &amp; &quot;\\&quot;\r\n\r\n\tSet objFolder = objFSO.GetFolder(sPath)\r\n\r\n\t' First recurse to any sub-folders, and remove files from them.\r\n\tIf bIncludeSubFolders Then\r\n\t\tFor Each objItem In objFolder.SubFolders\r\n\t\t\tCall RemoveFilesInFolder (sWorkPath &amp; objItem.Name, False)\r\n\t\tNext 'objItem\r\n\tEnd If\r\n\r\n\tWScript.Echo\r\n\tWScript.Echo &quot;--- &quot; &amp; sPath\r\n\r\n\t' First, enumerate the files and delete them.\r\n\tIf Not bAtTop Or Not bSpareRootFolder Then\r\n\t\tIf objFolder.Files.Count - nPreserveFileCount &gt; 0 Then\r\n\t\t\tReDim aSort (objFolder.Files.Count - 1)\r\n\t\t\tnI = 0\r\n\t\t\tFor Each objItem in objFolder.Files\r\n\t\t\t\tIf nDateToCheck = 0 Then\r\n\t\t\t\t\taSort (nI) = DateToAnsi (objItem.DateCreated) &amp; &quot;\\&quot; &amp; objItem.Name\r\n\r\n\t\t\t\tElseIf nDateToCheck = 1 Then\r\n\t\t\t\t\taSort (nI) = DateToAnsi (objItem.DateLastModified) &amp; &quot;\\&quot; &amp; objItem.Name\r\n\r\n\t\t\t\tElseIf nDateToCheck = 2 Then\r\n\t\t\t\t\taSort (nI) = DateToAnsi (objItem.DateLastAccessed) &amp; &quot;\\&quot; &amp; objItem.Name\r\n\r\n\t\t\t\tEnd If\r\n\t\t\t\tnI = nI + 1\r\n\t\t\tNext\r\n\r\n\t\t\tCall QuickSort (aSort, Empty, Empty)\r\n\r\n\t\t\tFor nI = 0 To UBound (aSort) - nPreserveFileCount\r\n\t\t\t\tsTmp = Split(aSort(nI), &quot;\\&quot;)(1)\r\n\t\t\t\t'WScript.Echo sTmp\r\n\t\t\t\tSet objFile = objFSO.GetFile (sWorkPath &amp; sTmp)\r\n\r\n\t\t\t\tIf Not FileMatchesPattern (objFile.Name, sFilePattern, True) Then\r\n\t\t\t\t\tbPardoned = True\r\n\t\t\t\t\t'WScript.Echo &quot;Name does not match filter pattern: &quot; &amp; objFile.Name\r\n\r\n\t\t\t\tElseIf bIgnoreZeroLengthFiles And objFile.Size = 0 Then\r\n\t\t\t\t\tbPardoned = True\r\n\t\t\t\t\tWScript.Echo &quot;Ignoring null-length file: &quot; &amp; objFile.Name\r\n\r\n\t\t\t\tElseIf Not bAggressive And (objFile.Attributes AND 7) &lt;&gt; 0 Then\r\n\t\t\t\t\tWScript.Echo &quot;Attribute-protected file ignored: &quot; &amp; objFile.Name\r\n\t\t\t\t\tbPardoned = True\r\n\r\n\t\t\t\tElseIf nDateToCheck = 0 And DateAdd (&quot;d&quot;, 0, objFile.DateCreated) &gt; dCutOff Then\r\n\t\t\t\t\tWScript.Echo &quot;Young file kept: &quot; &amp; objFile.Name\r\n\t\t\t\t\tbPardoned = True\r\n\r\n\t\t\t\tElseIf nDateToCheck = 1 And DateAdd (&quot;d&quot;, 0, objFile.DateLastAccessed) &gt; dCutOff Then\r\n\t\t\t\t\tWScript.Echo &quot;Young file kept: &quot; &amp; objFile.Name\r\n\t\t\t\t\tbPardoned = True\r\n\r\n\t\t\t\tElseIf nDateToCheck = 2 And DateAdd (&quot;d&quot;, 0, objFile.DateLastModified &gt; dCutOff) Then\r\n\t\t\t\t\tWScript.Echo &quot;Young file kept: &quot; &amp; objFile.Name\r\n\t\t\t\t\tbPardoned = True\r\n\r\n\t\t\t\tElseIf bTestRun Then\r\n\t\t\t\t\tWScript.Echo &quot;Qualifies for deletion: &quot; &amp; objFile.Name\r\n\t\t\t\t\tbPardoned = True\r\n\r\n\t\t\t\tElse\r\n\t\t\t\t\tbPardoned = False\r\n\r\n\t\t\t\tEnd If\r\n\r\n\t\t\t\tIf Not bPardoned Then\r\n\t\t\t\t\tErr.Clear\r\n\t\t\t\t\tsFileName = objFile.Name\r\n\t\t\t\t\tOn Error Resume Next\r\n\t\t\t\t\tobjFile.Delete\r\n\t\t\t\t\tiErr = Err.Number\r\n\t\t\t\t\tOn Error Goto 0\r\n\t\t\t\t\tIf iErr = 0 Then\r\n\t\t\t\t\t\tWScript.Echo &quot;Deleted: &quot; &amp; objFile.Name\r\n\t\t\t\t\tElse\r\n\t\t\t\t\t\tWScript.Echo &quot;Could not delete: &quot; &amp; objFile.Name\r\n\t\t\t\t\tEnd If\r\n\t\t\t\tEnd If\r\n\t\t\t\tSet objFile = Nothing\r\n\t\t\tNext ' File\r\n\t\tEnd If\r\n\tEnd If\r\n\r\n\t' Remove the folder if it is empty, and the option to remove empty folders has been selected.\r\n\t' NOTE: We don't delete the folder if any files are detected in it--protected or not.\r\n\tIf (Not bAtTop Or bSpareRootFolder) And bRemoveEmptyFolders Then\r\n\r\n\t\tbPardoned = False\r\n\t\tFor Each objItem In objFolder.Files\r\n\t\t\tbPardoned = True\r\n\t\t\tExit For\r\n\t\tNext\r\n\t\tFor Each objItem In objFolder.SubFolders\r\n\t\t\tbPardoned = True\r\n\t\t\tExit For\r\n\t\tNext\r\n\t\t\r\n\t\tIf Not bPardoned Then\r\n\t\t\tErr.Clear\r\n\t\t\tOn Error Resume Next\r\n\t\t\tobjFolder.Delete\r\n\t\t\tiErr = Err.Number\r\n\t\t\tOn Error Goto 0\r\n\t\t\tIf iErr = 0 Then\r\n\t\t\t\tWScript.Echo &quot;Killed empty folder...&quot;\r\n\t\t\tElse\r\n\t\t\t\tWScript.Echo &quot;Empty folder survived (may contain hidden or system files)...&quot;\r\n\t\t\tEnd If\r\n\t\tEnd If\r\n\tEnd If\r\n\r\n\tSet objItem = Nothing\r\n\tSet objFolder = Nothing\r\n\tSet objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)\r\n\r\nEnd Sub\r\n\r\nSub HandleError (iErr, sErr)\r\n\r\n\tIf bBatchMode Then\r\n\t\tLogAnEvent 1, sMsg\r\n\tElse\r\n\t\tWScript.Echo sMsg\r\n\tEnd If\r\n\r\nEnd Sub\r\n\r\nSub Usage ()\r\n\tWScript.Echo &quot;DeleteOldFiles.vbs -- Remove files older than a specified number of days from one or more folders. &quot;\r\n\tWScript.Echo &quot;John J Schultz -- 12\/12\/2005 -- Public Domain. &quot;\r\n\tWScript.Echo &quot; &quot;\r\n\tWScript.Echo &quot;cscript DeleteOldFiles.vbs [{switches}] {days} folder [pattern]&quot;\r\n\tWScript.Echo &quot; &quot;\r\n\tWScript.Echo &quot;- Days is the age (in days) of the file's time stamp, to remove the file. Default: 30 days &quot;\r\n\tWScript.Echo &quot;- Folder is an existing folder containing the files targeted for removal. &quot;\r\n\tWScript.Echo &quot;- pattern is a regular expression used to filter matching file names targeted for removal. If not present, all files are included.&quot;\r\n\tWScript.Echo &quot; &quot;\r\n\tWScript.Echo &quot;-------------------------- Available switches --------------------------- &quot;\r\n\tWScript.Echo &quot;\/t   - test only (a.k.a. chicken run): shows files affected, but does not actually delete them.&quot;\r\n\tWScript.Echo &quot;\/a   - aggressive: attempts to remove read-only files. &quot;\r\n\tWScript.Echo &quot;\/s   - recurse files in subdirectories. &quot;\r\n\tWScript.Echo &quot;\/d   - remove a sub-directory if it is empty after removing files (does not include the initial folder). &quot;\r\n\tWScript.Echo &quot;\/b   - run in batch mode (errors logged to NT Event Log) &quot;\r\n\tWScript.Echo &quot;\/r   - spares files in the initial (root) folder.  Use with \/s when only files in sub-folders &quot;\r\n\tWScript.Echo &quot;       should be removed.  If this switch is used without \/s, it has no effect. &quot;\r\n\tWScript.Echo &quot;\/0-  - ignores files with zero-length. &quot;\r\n\tWScript.Echo &quot;\/d:c[reate]   - (default) uses creation date to measure age.  Note: Creation date on a copied &quot;\r\n\tWScript.Echo &quot;                file is the date it was copied (i.e.: it does not inherit the original file's &quot;\r\n\tWScript.Echo &quot;                creation date). &quot;\r\n\tWScript.Echo &quot;\/d:a[ccess]   - uses last access date to measure age. &quot;\r\n\tWScript.Echo &quot;\/d:m[odified] - uses last modified date to measure age. &quot;\r\n\tWScript.Echo &quot;\/n:# - preserve a count of files. Leaves at least this number of the newest files in the folder.&quot;\r\n\tWScript.Echo &quot;\/l:n - Log to NT Event Log: n = chatter level: &quot;\r\n\tWScript.Echo &quot;       0 = single summary &quot;\r\n\tWScript.Echo &quot;       1 = start\/completion &quot;\r\n\tWScript.Echo &quot;       2 = (1) and all failures &quot;\r\n\tWScript.Echo &quot;       3 = (2) and all successes &quot;\r\n\tWScript.Echo &quot;    NOTE: NT Event logging is performed if \/b (batch mode) is specified, otherwise messages &quot;\r\n\tWScript.Echo &quot;          are directed to the console. &quot;\r\n\tWScript.Echo &quot;------------------------------------------------------------------------ &quot;\r\n\tWScript.Echo &quot; &quot;\r\n\tWScript.Echo &quot;\/\/B is the switch recommended for production use with wscript to suppress operator messages from &quot;\r\n\tWScript.Echo &quot;the script engine (e.g. when launched from a timer).  Due to the number of WScript.Echo statements used, &quot;\r\n\tWScript.Echo &quot;CScript is highly recommended--even when testing. &quot;\r\nEnd Sub\r\n\r\n' ###################################################################################\r\n' MAIN\r\n\r\n' Module\r\nDim oFSO\r\nDim oFolder\r\nDim oFile\r\nDim oArgs\r\nDim nArgCnt\r\nDim iCount\r\nDim sApp\r\nDim bValidParameters\r\nDim sTmp\r\nDim sMsg\r\n\r\nsApp = &quot;DeleteOldFiles.vbs&quot;\r\n\r\nbTestRun = False\r\nbIncludeSubFolders = False\r\nbRemoveEmptyFolders = False\r\nbBenchmark = False\r\nbUserConfirmationForDelete = False\r\nbIgnoreZeroLengthFiles = False\r\nbTestOnly = False\r\nnDateToCheck = 2  ' Default to date modified.\r\nnDays = -1\r\nnPreserveFileCount = 0\r\nsStartFolder = &quot;&quot;\r\nsFilePattern = &quot;[.]+&quot;\r\n\r\nbValidParameters = True\r\n\r\nSet oArgs = WScript.Arguments\r\niCount = oArgs.Count\r\nIf iCount = 0 Then\r\n\tbValidParameters = False\r\nEnd If\r\n\r\nIf bValidParameters Then\r\n\tFor iCount = 0 to oArgs.Count - 1\r\n\t\tsTmp = LCase (LTrim (RTrim (oArgs(iCount))))\r\n\t\tIf Left (sTmp, 1) = &quot;\/&quot; Then\r\n\r\n\t\t\tIf sTmp = &quot;\/a&quot; Then\r\n\t\t\t\tbAggressive = True\r\n\r\n\t\t\tElseIf sTmp = &quot;\/t&quot; Then\r\n\t\t\t\tbTestRun = True\r\n\r\n\t\t\tElseIf sTmp = &quot;\/s&quot; Then\r\n\t\t\t\tbIncludeSubFolders = True\r\n\r\n\t\t\tElseIf sTmp = &quot;\/r&quot; Then\r\n\t\t\t\tbSpareRootFolder = True\r\n\r\n\t\t\tElseIf sTmp = &quot;\/d&quot; Then\r\n\t\t\t\tbRemoveEmptyFolders = True\r\n\r\n\t\t\tElseIf sTmp = &quot;\/b&quot; Then\r\n\t\t\t\tbBatchMode = False\r\n\r\n\t\t\tElseIf sTmp = &quot;\/q&quot; Then\r\n\t\t\t\tbUserConfirmationForDelete = True\r\n\r\n\t\t\tElseIf sTmp = &quot;\/0-&quot; Then\r\n\t\t\t\tbIgnoreZeroLengthFiles = True\r\n\r\n\t\t\tElseIf Left (sTmp &amp; Space (4), 4) = &quot;\/d:c&quot; Then\r\n\t\t\t\tnDateToCheck = 0\r\n\r\n\t\t\tElseIf Left (sTmp &amp; Space (4), 4) = &quot;\/d:a&quot; Then\r\n\t\t\t\tnDateToCheck = 1\r\n\r\n\t\t\tElseIf Left (sTmp &amp; Space (4), 4) = &quot;\/d:m&quot; Then\r\n\t\t\t\tnDateToCheck = 2\r\n\r\n\t\t\tElseIf Left (sTmp &amp; Space (3), 3) = &quot;\/n:&quot; Then\r\n\t\t\t\tnPreserveFileCount = Int (Mid (sTmp &amp; Space (4), 4))\r\n\t\t\t\tIf nPreserveFileCount &lt; 0 Then\r\n\t\t\t\t\tWScript.Echo &quot;Invalid preserve count: &quot; &amp; nPreserveFileCount\r\n\t\t\t\t\tbValidParameters = False\r\n\t\t\t\tEnd If\r\n\r\n\t\t\tElse\r\n\t\t\t\tbValidParameters = False\r\n\t\t\t\tsMsg = &quot;unrecognized switch: &quot; &amp; sTmp\r\n\r\n\t\t\tEnd If\r\n\r\n\t\tElseIf nDays = -1 And Instr (&quot;0123456789&quot;, Left (sTmp, 1)) &gt; 0 Then\r\n\t\t\ton error resume next\r\n\t\t\tnDays = CInt (sTmp)\r\n\t\t\ton error goto 0\r\n\t\t\tIf nDays &lt; 0 Then\r\n\t\t\t\tbValidParameters = False\r\n\t\t\t\tsMsg = &quot;day count must be &gt;= 0: &quot; &amp; sTmp\r\n\t\t\tEnd If\r\n\r\n\t\tElseIf sStartFolder = &quot;&quot; Then\r\n\t\t\tsStartFolder = LTrim (RTrim (oArgs(iCount)))\r\n\r\n\t\tElseIf sFilePattern = &quot;[.]+&quot; Then\r\n\t\t\tsFilePattern = LTrim (RTrim (oArgs(iCount)))\r\n\r\n\t\tElse\r\n\t\t\tbValidParameters = False\r\n\t\t\tsMsg = _\r\n\t\t\t&quot;Attempt to re-specify the folder: &quot; &amp; sTmp &amp; vbCrLf &amp; _\r\n\t\t\t&quot;Already set as: &quot; &amp; sStartFolder\r\n\t\tEnd If\r\n\tNext\r\nEnd If\r\n\r\nSet objArgs = Nothing\r\n\r\nIf sStartFolder = &quot;&quot; Then\r\n\tsMsg = _\r\n\t&quot;No starting folder specified&quot;\r\n\tbValidParameters = False\r\nEnd If\r\n\r\nIf Not bValidParameters Then\r\n\tIf bBatchMode Then\r\n\t\tLogAnEvent 1, sMsg\r\n\tElse\r\n\t\tWScript.Echo sMsg\r\n\tEnd If\r\n\tCall Usage()\r\n\tWScript.Quit (1)\r\nEnd If\r\n\r\nIf nDays &lt; 0 Then nDays = 30\r\n\r\ndCutOff = DateAdd (&quot;d&quot;, -nDays, Now ())\r\n\r\nWScript.Echo &quot;Removing files older than &quot; &amp; nDays &amp; &quot; days (cutoff time: &quot; &amp; dCutoff &amp; &quot;)&quot;\r\nWScript.Echo &quot;Expiration is evaluated on the &quot; &amp; Split (&quot;creation|last access|last modification&quot;, &quot;|&quot;)(nDateToCheck) &amp; &quot; timestamp.&quot;\r\n\r\n' --- Processing starts here\r\nCall RemoveFilesInFolder (sStartFolder, True)\r\n\r\nWScript.Echo &quot;Script completed&quot;\r\n\r\nWScript.Quit(0)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve had this script around for some time, and thought I would share it. There are many utilities that will do this, but this one is designed for VBScript, and uses regular expressions for the file pattern. This allows for almost surgical removal of files from a working folder or archive folder. I&#8217;ve used this [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-5","post","type-post","status-publish","format-standard","hentry","category-vbscript-intended-for-command-line-batch-usage"],"_links":{"self":[{"href":"https:\/\/blog.bitsofgenius.com\/index.php?rest_route=\/wp\/v2\/posts\/5","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bitsofgenius.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bitsofgenius.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bitsofgenius.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bitsofgenius.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5"}],"version-history":[{"count":1,"href":"https:\/\/blog.bitsofgenius.com\/index.php?rest_route=\/wp\/v2\/posts\/5\/revisions"}],"predecessor-version":[{"id":417,"href":"https:\/\/blog.bitsofgenius.com\/index.php?rest_route=\/wp\/v2\/posts\/5\/revisions\/417"}],"wp:attachment":[{"href":"https:\/\/blog.bitsofgenius.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bitsofgenius.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bitsofgenius.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}