Jump to content

ok you scripting gurus - i need some help


Recommended Posts

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

Link to comment
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
Link to comment
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

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...