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

Thanks to everyone - I now have the solution! I can detect comporession using Win32::File, then remove it using compact /u . Tim
  • Comment on Re^2: How to remove COMPRESSED attribute with Win32::File?

Replies are listed 'Best First'.
Re^3: How to remove COMPRESSED attribute with Win32::File?
by BrowserUk (Patriarch) on Mar 06, 2009 at 16:03 UTC

    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.

      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"; }