A quick idea is to use Get-ChildItem
with the -Directory
and -Recurse
options and use Start-Process
and its -ArgumentList
option to execute the python script passing it the full directory path.
1. Simple script (use to test specific folder(s))
$src = "C:\Folder\Path";
(Get-ChildItem $src -Directory -Recurse).FullName | % { Process {
Start-Process Python -ArgumentList "./convert.py $($_)" } };
2. PowerShell script with execution arg value
$src = $args[0];
(Get-ChildItem $src -Directory -Recurse).FullName | % { Process {
Start-Process Python -ArgumentList "./convert.py $($_)" } };
Executing the above #2 PowerShell script
powershell.exe -ExecutionPolicy Bypass -File "C:\PowerShell\PScript.ps1" "C:\Folder\123\678"
3. One more example (recursive files)
Note: In case the Python script needs the file path passed to it, use this example with the -File
parameter this will pass the file paths. I'm not sure what the Python script is doing though.
$src = "C:\Folder\Path";
(Get-ChildItem $src -Recurse -File).FullName | % { Process {
Start-Process Python -ArgumentList "./convert.py $($_)" } };
Supporting Resources