Skip to content

Instantly share code, notes, and snippets.

@franklindyer
Created May 29, 2024 22:22
Show Gist options
  • Save franklindyer/970be067c20fd56c1b8fd09dbf25e3ae to your computer and use it in GitHub Desktop.
Save franklindyer/970be067c20fd56c1b8fd09dbf25e3ae to your computer and use it in GitHub Desktop.
# USAGE: .\multidir.ps1 --dirs "directory1,...,directoryn"
# Execute a sequence of commands sequentially in each of the directories
param (
[string]$dirs = ""
)
$dirlist = $dirs.Split(",")
While (($cmd = Read-Host -Prompt "multidir> ") -ne "exit") {
ForEach ($dir in $dirlist) {
pushd $dir
Invoke-Expression $cmd
popd
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment