Jump to content

Folder Monitor


Recommended Posts

Hey Guys,

I wanted to get hold of a script or get any ideas on how to make a script that will watch a folder and then display a message is the contects of that folder changes. Ie/ Watch the desktop and as soon as someone saves a file there the message displays "You should not save files to your desktop."

Any help would be greatly appreciated.

Cheers,

Michael

Here's what I have made tonight. Nice and basic - would like any comments if anyone has some to improve it. It works but I am not a programmer.

$InitialSize = DirGetSize(@DesktopDir)

CheckSize()

Func CheckSize()

While 1

$MonitoredSize = DirGetSize(@DesktopDir)

If $MonitoredSize > $InitialSize Then

MsgBox(0,"","You should not save files on your desktop. When you reboot they wil be erased.")

Else

;Do Nothing

EndIf

Sleep(2000)

$InitialSize = $MonitoredSize

WEnd

CheckSize()

EndFunc

Edited by ca143508
Link to comment
Share on other sites

Global $PathSize = DirGetSize(@DesktopDir, 1)
HotKeySet("{ESC}", "Terminate")

AdlibEnable('_FolderMonitor')

While 1
    Sleep(50)
WEnd

Func _FolderMonitor()
    Local $iSize = DirGetSize(@DesktopDir, 1)
    If $iSize[1] <> $PathSize[1] Or $iSize[2] <> $PathSize[2] Then 
        If $iSize[1] < $PathSize[1] Then MsgBox(16,"Warning...","You should not delete files from your desktop.")
        If $iSize[2] < $PathSize[2] Then MsgBox(16,"Warning...","You should not deleting folders from your desktop.")
        If $iSize[1] > $PathSize[1] Then MsgBox(16,"Warning...","You should not save files to your desktop.") 
        If $iSize[2] > $PathSize[2] Then MsgBox(16,"Warning...","You should not save folders to your desktop.")
        $PathSize[1] = $iSize[1]
        $PathSize[2] = $iSize[2]
    EndIf
EndFunc

Func Terminate()
    Exit 0
EndFunc
Press ESC to exit script.

Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

@Danny35d

Is your script checking if a file's size is getting smaller and thus saying that message about not deleting a file (vice versa for size getting bigger)? If so wouldn't that mean that you would gradually lose the file/ damage it if you continuously try to delete that file?

If not, then what is the script doing?

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

The original goal was to monitor the desktop folder and if it's size increases, prompt the user about the dangers of saving files to a local system that automatically restores to it's original state on reboot. It will also make a copy of any files on the desktop in a network share so that should they re-boot and ignore the error messages they were getting, we can easily restore the files or send them to the network share to edit them.

Cheers

Michael

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...