Jump to content

Has anyone setup a script to monitor and 7zip a folder?


tnek
 Share

Recommended Posts

Before I re-invent the wheel - has anyone written anything to monitor a folder and zip it's contents when something new shows? I want to automate zipping our db backups for offsite storage and was hoping something similar exists. Thanks.

Link to comment
Share on other sites

  • Moderators

tnek,

I have never seen one.  But you should begin the research for your own script with seangriffin's FileSystemMonitor UDF - that will give you the "new file" bit.  There are a couple of 7-Zip threads about if you search which will help with the rest. ;)

I look forward to seeing the finished article one day. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

tnek,

You know where we are if you run into problems. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Well here is the current code. The folder monitoring code has not been written yet as time has been limited.

;~ =========================================================================================
;~ Lets a user pick a folder and currently only 7zips .bak and .trn files
;~ I wrote this to minimize space used on our backup storage server
;~
;~ by Kent Kroft   2.8.2012
;~  Version 1.0 
;~   STEAL AND MODIFY AT YOUR PLEASURE  - JUST POST YOUR IMPROVEMENTS
;~ =========================================================================================
#region ;Includes, Definitions, etc. ===============================================================
#include <File.au3>
#include <Date.au3>
#include <7Zip.au3>
#include <Array.au3>
#include <EventLog.au3>
Global $aFolders
Global $runLoop
Global $vPathName
Dim $aData[4] = [0, 0, 0, 0]
#endregion ;Includes, Definitions, etc. ===============================================================
#region ;Opens ==============================================================================
$runLoop = 1
$vPathName = FileSelectFolder("Choose a folder.", "", 4)
;~ $vPathName = @DesktopDir
;~ $vPathName = @ScriptDir
;~ $vPathName = 'H:ZippingPractice'
If @error Then
$runLoop = 0
EndIf
#endregion ;Opens ==============================================================================
#region ;Main ===============================================================================
While $runLoop = 1
$aFileList = _FileListToArray($vPathName, '*', 1)
For $j = 1 To $aFileList[0]
  $t = StringRight($aFileList[$j], 3)
  If ($t = "bak") Or ($t = "trn") Then
   $runLoop = _GoZip($vPathName & '' & $aFileList[$j])
  EndIf
  If $runLoop < 1 Then ExitLoop
Next
$runLoop = 0
WEnd
#endregion ;Main ===============================================================================
#region ; Functions ===========================================================================
Func _GoZip($inName)
$vZippedName =  StringLeft($inName, (StringLen($inName) - 4)) & "_" & StringRight($inName,3) & '.7z'
$retResult = _7ZipAdd(0, $vZippedName, $inName, 0, 9)
$hEventLog = _EventLog__Open("", "Folder_Zipper")
If $retResult = 0 Then
  _EventLog__Report($hEventLog, 1, 0, 2, "Administrator", "Failure Zipping: " & $inName, $aData)
  Return 0
Else
  $retResult = FileDelete($inName)
  If $retResult = 0 Then
   _EventLog__Report($hEventLog, 1, 0, 2, "Administrator", "Failure Removing: " & $inName, $aData)
   Return 0
  Else
   Return 1
  EndIf
EndIf
_EventLog__Close($hEventLog)
EndFunc   ;==>_GoZip
#endregion ; Functions ===========================================================================

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...