Sign in to follow this  
Followers 0
marcusdoc

ok you scripting gurus - i need some help

7 posts in this topic

how does one do a recursive directory scan? (I can see the utilization of FileFindFirstFile etc to perform a single directory scan but I don't see anything for directories).

here's the project

in a directory there are multiple directories contained within that are created on a daily basis. scan the directories contained within and only delete the directory (and it's contents) based upon age (say anything older than 14 days)

thanks in advance

Share this post


Link to post
Share on other sites



You might want to take a look at SendMessage,hlist,LB_DIR,DDL_FLAGS,addr path

The other constants for wParam are:

Const DDL_READWRITE = &H0
Const DDL_READONLY = &H1
Const DDL_HIDDEN = &H2
Const DDL_SYSTEM = &H4
Const DDL_DIRECTORY = &H10
Const DDL_ARCHIVE = &H20
Const DDL_DRIVES = &H4000
Const DDL_EXCLUSIVE = &H8000&
Const DDL_POSTMSGS = &H2000
Const DDL_FLAGS = DDL_ARCHIVE Or DDL_DIRECTORY

Share this post


Link to post
Share on other sites

Could be useful, AI 3.0.102 function to delete folder content (I use it to empty Favorites)

$favdir = @FavoritesDir

_DirRemoveContents($favdir)

Func _DirRemoveContents( $sPath )

  Local $sPattern

  Local $sFile

  Local $hFile

  If StringRight( $sPath, 1 ) <> "\" Then $sPath = $sPath & "\"

  $sPattern = $sPath & "*.*"

  If Not FileExists( $sPath ) Then Return 0

  FileDelete( $sPattern )

  $hFile = FileFindFirstFile( $sPattern )

  If @error Then Return 0

  While 1

    $sFile = FileFindNextFile( $hFile )

    If @error Then ExitLoop

    If $sFile <> "." And $sFile <> ".." Then

      If StringInStr( FileGetAttrib( $sPath & $sFile ), "D" ) Then

        DirRemove( $sPath & $sFile, 1 )

      EndIf 

    EndIf

  WEnd

  FileClose( $hFile )

  Return 1

EndFunc

Share this post


Link to post
Share on other sites

how does one do a recursive directory scan? (I can see the utilization of FileFindFirstFile etc to perform a single directory scan but I don't see anything for directories).

here's the project

in a directory there are multiple directories contained within that are created on a daily basis.  scan the directories contained within and only delete the directory (and it's contents) based upon age (say anything older than 14 days)

thanks in advance

<{POST_SNAPBACK}>

Posted this a while ago that does exactly what you are asking for : #30391

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Posted this a while ago that does exactly what you are asking for : #30391

<{POST_SNAPBACK}>

:) thanks everyone for your help

(now to figure out how this script works)

wow - that's complex scripting - great job

Edited by marcusdoc

Share this post


Link to post
Share on other sites
:) incredible - even with a log file and the ability to stop the process

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  
Followers 0