powershell_file_operations

Differences

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

Link to this comparison view

Next revision
Previous revision
powershell_file_operations [2021/10/18 14:38] – created mguptonpowershell_file_operations [2022/02/23 17:45] (current) mgupton
Line 2: Line 2:
  
 === Example of searching for files with cmd === === Example of searching for files with cmd ===
 +#search
  
 <code> <code>
 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.1634567927.txt.gz
  • Last modified: 2021/10/18 14:38
  • by mgupton