powershell_file_operations

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
powershell_file_operations [2021/10/22 14:21] mguptonpowershell_file_operations [2022/02/23 17:45] (current) mgupton
Line 7: Line 7:
 cmd /r dir /s /b c:\tmp\*.xml cmd /r dir /s /b c:\tmp\*.xml
 </code> </code>
 +
 +<code powershell>
 +get-childitem .\ -recurse | where {$_.extension -eq ".txt"} | foreach-object {
 +     Write-Host $_.FullName
 +}
 +</code>
 +
 +
 +=== Delete file if exists and recreate it ===
 +
 +<code powershell>
 +$filename = "c:\tmp\webapp1.zip"; If (Test-Path $filename) {Remove-Item $filename}; Compress-Archive -Path .\* -DestinationPath c:\tmp\webapp1.zip
 +</code>
 +
  • powershell_file_operations.1634912508.txt.gz
  • Last modified: 2021/10/22 14:21
  • by mgupton