7zip compress files (all or with specific extension) in folder and subfolder and delete original file

Customize to your needs:
#All file types
Get-ChildItem C:\temp\ -Recurse -File | ForEach-Object { & "C:\Program Files\7-Zip\7z.exe" a -sdel ($_.DirectoryName+"\"+$_.Name+".7z") ($_.DirectoryName+"\"+$_.Name)}
#Only .bak files
Get-ChildItem C:\temp\*.bak -Recurse -File | ForEach-Object { & "C:\Program Files\7-Zip\7z.exe" a -sdel ($_.DirectoryName+"\"+$_.Name+".7z") ($_.DirectoryName+"\"+$_.Name)}

Kommentarer

Populære opslag fra denne blog

Microsoft Office 2016 and the AUTO_ACTIVATE property

Access Exchange online with Office 365 multi-factor authentication (MFA/2FA)

Disable logon and logoff events (event id 4624, 4625, 4634 (and all the other ones...))