Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, October 20, 2010 2:58 AM | 1 vote
How do I set the compress bit for a file using a PS script? I'd like to compress all files in a folder with a script like gci | compress-item (made up).
Thank you.
All replies (5)
Wednesday, October 20, 2010 12:01 PM ✅Answered | 1 vote
Take a look at this
http://serverfault.com/questions/18872/how-to-zip-unzip-files-in-powershell
Wednesday, October 20, 2010 1:15 PM ✅Answered | 4 votes
As a quick way to set NTFS compression (not zip), I'll use the compact.exe command in PowerShell. For example:
$cmd = "compact.exe /C /S:myfile.txt"
cmd /c $cmd
Wednesday, October 20, 2010 9:48 PM ✅Answered | 1 vote
I wrote a post discussing a few zipping procedures. If I recall correctly there is a technical differention between compacting a file (with the compact.exe utlity) and compressing it (as in when you zip files). My post details compression and adding items to a zip file:
http://learningpcs.blogspot.com/2010/07/powershell-working-with-zip-files.html
Wednesday, February 24, 2016 5:18 AM
Nice cmille19, you could probably do something like this too:
$folder = Read-Host "Folder path?"
$task = "compact.exe /c /s:$folder"
CMD /C $task
Wednesday, March 16, 2016 8:35 PM
Get-ChildItem -File -Path "C:\test" -Recurse | ? {$_.attributes -notlike "*compressed*" | foreach {compact /C $_.FullName}
From: