Henry_Cornell Henry_Cornell - 1 year ago 111
PowerShell Question

loop through subfolders

Hi I would like to create a batch file to get all the sub-folders.Can anyone please help me on this?

Answer Source

This is trivial in both batch files or PowerShell:


for /r %%x in (*.sql) do (
    rem "(or whatever)"
    sqlcmd "%%x"


Get-ChildItem -Recurse -Filter *.sql |
    ForEach-Object {
        sqlcmd $_.FullName # or whatever
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download