Home > other >  How to display only the overwritten files while unzipping a .zip file?
How to display only the overwritten files while unzipping a .zip file?

Time:02-01

I am successfully able to extract contents of a file using:

Expand-Archive -Force -LiteralPath c:\folder\my_file.zip -DestinationPath c:\dest_folder

However, it is not displaying the files which are overwritten.

How to display only the files which are overwritten?

CodePudding user response:

If you really want to replace the existing files but also know which ones where replaced, an alternative would be to redirect the verbose stream to the success stream and filter by those lines containing "Remove File". Expand-Archive when using -Verbose, will output the following when replacing (removing first and then creating) a file:

Performing the operation "Remove File" on target .....

In that sense, you can do the following:

Expand-Archive -LiteralPath .\my_file.zip -DestinationPath .\Destination\ -Force -Verbose 4>&1 |
Select-String 'Remove File'
  •  Tags:  
  • Related