DISQUS

Tech-Recipes: PowerShell: Quick Way to Check for a File Type on a Drive or Directory | Windows | Tech-Recipes

  • Anonymous · 2 years ago
    Can this be done recursively? In other words, can I test-path for all files in the path and every subdirectory of the path?

    btw, thanks for a great blog.
  • Anonymous · 2 years ago
    does it have to be powershell? without installing powershell, you can use vbscript
    Set objFSO = CreateObject("Scripting.FilesyStemObject")
    myFolder="c:"
    Set objFolder = objFSO.GetFolder(myFolder)
    GoSubFolders objFolder

    Sub GoSubFolders (objDIR)
    If objDIR <> "System Volume Information" Then
    MainSub objDIR
    For Each eFolder in objDIR.SubFolders
    GoSubFolders eFolder
    Next
    End If

    End Sub

    Sub MainSub (objDIR)
    For Each efile in objDIR.Files
    WScript.Echo "File ", eFile, "is a ", eFile.Type
    Next
    End Sub


    save it as .vbs extension, type cscript myscript.vbs