locked
Compress old files using PowerShell script RRS feed

  • Question

  • Looking for a PowerShell script which can auto compress old files in a specified folder on the server. I am not supposed to install any third party tool like 7zip on the server. Files which has to be compressed should be validated against last modified date later than X days.
    Sunday, December 21, 2014 12:20 AM

Answers

All replies

  • There is no auto-compress functio in PowerShell.

    Just set the folder to compressed and the system will compress all files.


    ¯\_(ツ)_/¯

    Sunday, December 21, 2014 2:22 AM
  • Is there any other way to compress the files without installing any third party tool?
    Sunday, December 21, 2014 2:33 AM
  • Right click on folder - select properties - click advanced - check "Compress files".  All files in folder will be compressed.

    ¯\_(ツ)_/¯

    Sunday, December 21, 2014 2:38 AM
  • I do not want to compress the files manually. I need a script to compress the files which are older than a month in a particular folder. I want to schedule this script to run everyday.
    Sunday, December 21, 2014 2:54 AM
  • THere is no compresion utility in WIndows.  Yuo can set a file to have all files compressed.  You can install a third party compression utility and use that.  You can also install PowerShell 3.0 (WMF 3.0) and use the file compresssion classes but you will have to learnhow to write a script.

    I recommend 7Zip.  It does not have to be installed.


    ¯\_(ツ)_/¯

    Sunday, December 21, 2014 3:03 AM
    • Marked as answer by Gyanendra K Wednesday, December 24, 2014 1:45 PM
    Sunday, December 21, 2014 3:05 AM