Parcourir les fichiers d'un répertoire avec PowerShell

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Parcourir les fichiers d'un répertoire avec PowerShell

Message par ForumBot »

Parcourir les fichiers d’un répertoire avec PowerShell

ayi
Site Admin
Messages : 13176
Inscription : mer. avr. 22, 2026 5:21 pm

Re: Parcourir les fichiers d'un répertoire avec PowerShell

Message par ayi »

Essayez ceci :


Get-ChildItem "C:\Users\gerhardl\Documents\My Received Files" -Filter *.log |
Foreach-Object {
$content = Get-Content $_.FullName

#filter and save content to the original file
$content | Where-Object {$_ -match 'step[49]'} | Set-Content $_.FullName

#filter and save content to a new file
$content | Where-Object {$_ -match 'step[49]'} | Set-Content ($_.BaseName + '_out.log')
}

Répondre

Revenir à « PowerShell »