|
|
Line 618: |
Line 618: |
|
printf(fil, '%s\n'); |
|
printf(fil, '%s\n'); |
|
endwhile;</lang> |
|
endwhile;</lang> |
|
|
|
|
⚫ |
=={{header|PowerShell}}== |
|
⚫ |
In PowerShell the <code>Get-ChildItem</code> cmdlet allows for recursive filtering on file names with simple wildcards: |
|
⚫ |
<lang powershell>Get-ChildItem -Recurse -Include *.mp3</lang> |
|
⚫ |
For more complex filtering criteria the result of <code>Get-ChildItem</code> can be piped into the <code>Where-Object</code> cmdlet: |
|
⚫ |
<lang powershell>Get-ChildItem -Recurse | |
|
⚫ |
Where-Object { $_.Name -match 'foo[0-9]' -and $_.Length -gt 5MB }</lang> |
|
⚫ |
To perform an action on every matching file the results can be piped into the <code>ForEach-Object</code> cmdlet: |
|
⚫ |
<lang powershell>Get-ChildItem -Recurse | |
|
⚫ |
Where-Object { $_.Name -match 'foo[0-9]' } | |
|
⚫ |
ForEach-Object { ... }</lang> |
|
⚫ |
''Note:'' To include only ''files'' instead of directories too each of the above needs an additional<code>Where-Object</code> filter: |
|
⚫ |
<lang powershell>| Where-Object { !$_.PSIsContainer }</lang> |
|
|
|
|
|
=={{header|Python}}== |
|
=={{header|Python}}== |
Line 665: |
Line 678: |
|
for f in d.walkfiles(pattern): |
|
for f in d.walkfiles(pattern): |
|
print f</lang> |
|
print f</lang> |
|
|
|
⚫ |
=={{header|PowerShell}}== |
|
⚫ |
In PowerShell the <code>Get-ChildItem</code> cmdlet allows for recursive filtering on file names with simple wildcards: |
|
⚫ |
<lang powershell>Get-ChildItem -Recurse -Include *.mp3</lang> |
|
⚫ |
For more complex filtering criteria the result of <code>Get-ChildItem</code> can be piped into the <code>Where-Object</code> cmdlet: |
|
⚫ |
<lang powershell>Get-ChildItem -Recurse | |
|
⚫ |
Where-Object { $_.Name -match 'foo[0-9]' -and $_.Length -gt 5MB }</lang> |
|
⚫ |
To perform an action on every matching file the results can be piped into the <code>ForEach-Object</code> cmdlet: |
|
⚫ |
<lang powershell>Get-ChildItem -Recurse | |
|
⚫ |
Where-Object { $_.Name -match 'foo[0-9]' } | |
|
⚫ |
ForEach-Object { ... }</lang> |
|
⚫ |
''Note:'' To include only ''files'' instead of directories too each of the above needs an additional<code>Where-Object</code> filter: |
|
⚫ |
<lang powershell>| Where-Object { !$_.PSIsContainer }</lang> |
|
|
|
|
|
|
=={{header|R}}== |
|
=={{header|R}}== |