I have a large and complex nested folder structure on disk. Say,

<many files>
  <many files>
  <many files>

Compressing all the files would take few hours, so I would like to set Compressed attribute only on folders. That would leave existing files unchanged, but new files added in the future would become compressed.

Is there a way to achieve that using compact.exe command line?

  • A few hours, then I suggest you do it at nighttime. (Perhaps this is moere suited for Stackoverflow, voting for moving).
    – r4.
    Oct 18, 2013 at 8:58

1 Answer 1


It may not be completely clear from the output of compact /?, but when you use compact /c C:\somefolder, only the folder's compressed attribute is set, while the files inside the folder keep their current compressed attribute unchanged.

What you want to do is:
compact /c Folder1 cd Folder1 for /f "delims=" %i in ('@dir /b /s /a:d') do compact /c "%i".

If you should later intend to compress all the files, repeat the latter two commands, but omit the /a:d.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .