Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For background/context see <a href="https://stackoverflow.com/a/13416248/603855">this skeleton for recursive <em>file</em> access</a>. Given this folder structure:</p> <pre><code>tree /A ..\test Folder PATH listing for volume eh Volume serial number is 0ED6-233C E:\TRIALS\SOTRIALS\ANSWERS\13415663\TEST +---vbs \---df +---1 | +---b | | \---x | \---a | \---abc \---2 \---abc \---xx </code></pre> <p>and this proof of concept code:</p> <pre><code>Option Explicit Dim goFS : Set goFS = CreateObject("Scripting.FileSystemObject") WScript.Quit Main() Function Main() Dim sDir : sDir = "..\test" Dim oWorker : Set oWorker = New cWorker Main = traverseDir(goFS.GetFolder(sDir), oWorker) End Function Class cWorker Public Sub processFile(oFile) ' not needed End Sub Public Function processFolder(oFolder) WScript.Echo "looking at", oFolder.Path processFolder = True If "abc" = oFolder.Name Then WScript.Echo "will delete", oFolder.Path oFolder.Delete processFolder = False End If End Function End Class Function traverseDir(oDir, oWorker) traverseDir = 0 Dim oF For Each oF In oDir.Files oWorker.processFile oF Next For Each oF In oDir.SubFolders If oWorker.processFolder(oF) Then traverseDir = traverseDir(oF, oWorker) End If Next End Function </code></pre> <p>Output:</p> <pre><code>cscript step02.vbs looking at E:\trials\SoTrials\answers\13415663\test\vbs looking at E:\trials\SoTrials\answers\13415663\test\df looking at E:\trials\SoTrials\answers\13415663\test\df\1 looking at E:\trials\SoTrials\answers\13415663\test\df\1\b looking at E:\trials\SoTrials\answers\13415663\test\df\1\b\x looking at E:\trials\SoTrials\answers\13415663\test\df\1\a looking at E:\trials\SoTrials\answers\13415663\test\df\1\a\abc will delete E:\trials\SoTrials\answers\13415663\test\df\1\a\abc looking at E:\trials\SoTrials\answers\13415663\test\df\2 looking at E:\trials\SoTrials\answers\13415663\test\df\2\abc will delete E:\trials\SoTrials\answers\13415663\test\df\2\abc </code></pre> <p>Evidence:</p> <pre><code>tree /A ..\test Folder PATH listing for volume eh Volume serial number is 0ED6-233C E:\TRIALS\SOTRIALS\ANSWERS\13415663\TEST +---vbs \---df +---1 | +---b | | \---x | \---a \---2 </code></pre> <p>you should be able to write a script that solves your specific problem.</p> <p><strong>UPDATE:</strong></p> <p>Look <a href="https://stackoverflow.com/a/13453705/603855">here</a> to see the approach applied to moving folders.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload