none
Powershell script to comprss files with specefic options RRS feed

  • Question

  • We have process that creates lots of text & xml files in a particular folder. The files are then copied to a FTP location and moved to 'Processed' folder. I am looking for a process to archive the processed folder.

    Basically the script will accept following input parameters and compress them to a destination ZIP file. Finally, delete the source files once they are compressed.

    Example:

    $SourcePath = 'C:\Temp\Inputfiles'

    $IncludeSubFolders = 'Yes\No'

    $TargetCompressFilePath = 'C:\Temp\Target'

    $FilesToCompress = '*.txt, *.xml'

    $FilesOlderThan = 7

    Thanks!


    spp

    Monday, September 8, 2014 11:42 PM

Answers

  • Basically the script will accept following input parameters and compress them to a destination ZIP file. Finally, delete the source files once they are compressed.

    What script?

    If you need someone to write a script for you, you are asking in the wrong place. That said, you can search the repository or post a script request.


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by sppdba Tuesday, September 9, 2014 10:45 PM
    Monday, September 8, 2014 11:46 PM
    Moderator

All replies

  • Basically the script will accept following input parameters and compress them to a destination ZIP file. Finally, delete the source files once they are compressed.

    What script?

    If you need someone to write a script for you, you are asking in the wrong place. That said, you can search the repository or post a script request.


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by sppdba Tuesday, September 9, 2014 10:45 PM
    Monday, September 8, 2014 11:46 PM
    Moderator
  • The easiest and fastest way to do this is to use a commandline compressor like 7Zip , PkZip or WinZip.  All of them do all of those things already.


    ¯\_(ツ)_/¯

    Tuesday, September 9, 2014 12:08 AM
  • Thanks for the info. I was trying to use WinZip and didn't find an easy way to compress files based on a date filter (e.g. compress files older than 7 days and delete).

    spp

    Tuesday, September 9, 2014 10:42 PM
  • Thanks for the info. I was trying to use WinZip and didn't find an easy way to compress files based on a date filter (e.g. compress files older than 7 days and delete).

    spp

    The very latest version of WinZip does this I believe.  You may have to get the commandline version.

    With 7Zip you can get a list of files to "move" and pass them to 7Zip.

    Post your questions in 7Zip forums and WinZip forums.


    ¯\_(ツ)_/¯

    Tuesday, September 9, 2014 10:52 PM