flxfxp Posted May 6, 2009 Share Posted May 6, 2009 Hello, I'm thinking about writing a script that recursively monitors a directory for newly added files. Can any of you share your infinite wisdom on how to do this (efficiently)? Thanks and regards, Dennis Link to comment Share on other sites More sharing options...
Xenobiologist Posted May 6, 2009 Share Posted May 6, 2009 Hi, just store name, size and timestamp in an array and then loop through it and compare to the actual dir. Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
LurchMan Posted May 6, 2009 Share Posted May 6, 2009 a combination of _FileListToArray () and FileGetTime () should do the trick such as: $array = _FileListToArray($sPath, "") For $n = 1 to UBound ($array) - 1 $time = FileGetTime($sPath & $array[$n], 1) If $time[3] & ":" & $time[4] > $Currtime Then FileWriteLine ($sLog, $iline, $sPath & $array[$n]) Next This is very rough and I know it won't work like this but it should give you a general idea...lemme know if u have any questions about it. Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
Aceguy Posted May 6, 2009 Share Posted May 6, 2009 now has recently add and removed. expandcollapse popup#include<array.au3> #include<file.au3> #Include <Misc.au3> $array = _FileListToArray(@DesktopDir&"\test\") $not_found=0 do sleep(1000) $array2= _FileListToArray(@DesktopDir&"\test\") if $array2[0]>=$array[0] Then for $c=1 to UBound($array2)-1 $seach=_ArraySearch($array,$array2[$c]) if @error Then $not_found=1 ConsoleWrite("The file "&$array2[$c]& " Has recently been added"&@Lf) EndIf Next Else for $c=1 to UBound($array)-1 $seach=_ArraySearch($array2,$array[$c]) if @error Then $not_found=1 ConsoleWrite("The file "&$array[$c]& " Has recently been removed"&@Lf) endif Next EndIf if $not_found=1 Then $array = _FileListToArray(@DesktopDir&"\test\") $not_found=0 EndIf until _IsPressed("1B") [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 6, 2009 Share Posted May 6, 2009 If you want to get down and geeky on it, there are scripts posted that monitor FileSystemObject (FSO) events for creation/deletion of files. Search is your friend. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
flxfxp Posted May 6, 2009 Author Share Posted May 6, 2009 If you want to get down and geeky on it, there are scripts posted that monitor FileSystemObject (FSO) events for creation/deletion of files. Search is your friend. Thats what I am thinking about. I'm currently working with the inotify stack in linux which does that too I think WMI can do it too.Thanks for some of the examples guys! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now