I'm new to Python (not to scripting). On Windows in PowerShell I can write:
PS C:\> (dir -Path C:\junk *.jpg -Recurse).FullName | C:\PS\scripts\EchoPipe.ps1
........
In shell: C:\junk\GIMP_TEST\LuminosityMask.JPG
........
Where EchoPipe.ps1 is:
foreach($x in $input) { # Is anything similar to $input in Python?
Write-Output('In shell: '+$x)
}
Write-Output('... and now I can process them')
How to do this in Python?
Q1: The left side of the pipe can be written in this way:
import os
import re
for d,x,fl in os.walk('C:\\junk'):
for f in fl:
if re.search(r'.jpg$', f, re.I):
print(d+os.sep+f)
Is there a simpler way?
Q2: How to write the equivalent of EchoPipe.ps1 in Python? And, most importantly, how to run them using pipeing? Do I run it in a Command Prompt or in Python 3... Shell and how? Please, be very detailed.