Jump to content
Sign in to follow this  
Jcreator

when ever a folder is add in the selected path show it name

Recommended Posts

Jcreator

i need to have a script that when ever a folder is add in the selected path show it name but somehow  it calls the Folder that was before that one and after that it keep calling it. the same folder again and again when ever a new folder is added   

#include <file.au3>
#include <array.au3>

Global $spath = ("C:\T-in")
$checkpath = StringRegExp($spath,"^.+\\$",0)
If $checkpath = 0 Then $spath = $spath & "\"

$aArray = _FileListToArray($spath,"*",$FLTAR_FOLDERS)

Func NewestFolder()

Global $aArray2D[10][2]
ReDim $aArray2D[$aArray[0]+1][2]
$aArray2D[0][0] = $aArray[0]

For $i=1 to $aArray[0]
    $aArray2D[$i][0] = $aArray[$i]
    $aArray2D[$i][1] = FileGetTime($spath & $aArray[$i],0,1)
Next
_ArraySort($aArray2D,1,1,"",1)
Global $newfolder = $aArray2D[1][0]
MsgBox(0, "", "a folder has been added .it name is :"& $newfolder)
EndFunc


While 1
While 2
$dnumX = DirGetSize($spath, 1)
    Sleep(500)
 $dnumY = DirGetSize($spath, 1)
If $dnumX[2] <> $dnumY[2] Then  NewestFolder()
     ExitLoop
WEnd

WEnd

 

Share this post


Link to post
Share on other sites
AutoBert

Move this line: < $aArray = _FileListToArray($spath,"*",$FLTAR_FOLDERS) > before the loop in the func NewestFolder.

 

I also found a very interesting script monitoring a Folder:WatchFolder.au3

Share this post


Link to post
Share on other sites
Jcreator

Thank you soooooo much bro it did work ^^ 

 

#include <file.au3>
#include <array.au3>

Global $spath = ("C:\T-in")
$checkpath = StringRegExp($spath,"^.+\\$",0)
If $checkpath = 0 Then $spath = $spath & "\"



Func NewestFolder()
$aArray = _FileListToArray($spath,"*",$FLTAR_FOLDERS)

Global $aArray2D[10][2]
ReDim $aArray2D[$aArray[0]+1][2]
$aArray2D[0][0] = $aArray[0]

For $i=1 to $aArray[0]
    $aArray2D[$i][0] = $aArray[$i]
    $aArray2D[$i][1] = FileGetTime($spath & $aArray[$i],0,1)
Next
_ArraySort($aArray2D,1,1,"",1)
Global $newfolder = $aArray2D[1][0]
MsgBox(0, "", "a folder has been added .it name is :"& $newfolder)
EndFunc


While 1
While 2
$dnumX = DirGetSize($spath, 1)
    Sleep(500)
 $dnumY = DirGetSize($spath, 1)
If $dnumX[2] <> $dnumY[2] Then  NewestFolder()
     ExitLoop
WEnd

WEnd


 

Share this post


Link to post
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
Sign in to follow this  

×