in reply to Re^2: How to remove COMPRESSED attribute with Win32::File?
in thread How to remove COMPRESSED attribute with Win32::File?

Did you notice that compact can take a wildcard?

If you give it a directory name it will operate on all the files in that directory in one go which would be far quicker than discovering the files yourself and then calling the command for each file individually.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^4: How to remove COMPRESSED attribute with Win32::File?
by Le Pouet (Initiate) on Dec 19, 2013 at 19:36 UTC

    Sample of code to add/remove the compress attribute.

    $file_fullname="c:/temp/archiving.ini"; Win32::File::GetAttributes($file_fullname, $attr); if ($attr & COMPRESSED) { print "File is compressed. --> UnCompress \n"; $file_fullname=&change_file_to_uncompressed($file_fullname); } else { print "File is NOT compressed. --> Compress \n"; $file_fullname=&change_file_to_compressed($file_fullname); } sub change_file_to_compressed { my(@args) = @_; my $file_to_modify = $args[0]; $attrib_compress= "compact /C $file_to_modify"; qx "$attrib_compress"; } sub change_file_to_uncompressed { my(@args) = @_; my $file_to_modify = $args[0]; $attrib_compress= "compact /U $file_to_modify"; qx "$attrib_compress"; }