Jump to content

Sorting directories on timestamp


bubke
 Share

Recommended Posts

Heres how you can sort em

#include <array.au3>

$files = recursivefilesearch ("C:\windows\system32")



_arraydelete ($files , 0)
_arraysort($files)
_arraydisplay ($files)



;;;:::::WEAPON X's - RECURSIVE FILE SEARCH - PULLS FULL DIRECTORY AND NAME:::::::::::::::::::::::::::
Func RecursiveFileSearch ($startDir, $depth = 0)

If $depth = 0 Then Global $RFSstring = ""

$search = FileFindFirstFile($startDir & "\*.*")
If @error Then Return

;Search through all files and folders in directory
While 1
$next = FileFindNextFile($search)
If @error Then ExitLoop

;If folder, recurse
If StringInStr(FileGetAttrib($startDir & "\" & $next), "D") Then
    $time = filegettime ($startDir & "\" & $next, 0 , 1)

$RFSstring &= $time & "  -----  " & $startDir & "\" & $next & "*"
RecursiveFileSearch ($startDir & "\" & $next, $depth + 1)
Else
;Append filename to master string

$time = filegettime ($startDir & "\" & $next, 0 , 1)

$RFSstring &= $time & "  -----  " & $startDir & "\" & $next & "*"
EndIf
WEnd
FileClose($search)

If $depth = 0 Then Return (StringSplit(StringTrimRight($RFSstring, 1), "*"))

EndFunc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;==>RecursiveFileSearch

Scrubbed for everything from september forward::

#include <array.au3>

$files = recursivefilesearch ("C:\windows\system32")

_arraydelete ($files , 0)

_arraysort($files)

_arraydisplay ($files)

;;;:::::WEAPON X's - RECURSIVE FILE SEARCH - PULLS FULL DIRECTORY AND NAME:::::::::::::::::::::::::::

Func RecursiveFileSearch ($startDir, $depth = 0)

If $depth = 0 Then Global $RFSstring = ""

$search = FileFindFirstFile($startDir & "\*.*")

If @error Then Return

;Search through all files and folders in directory

While 1

$next = FileFindNextFile($search)

If @error Then ExitLoop

;If folder, recurse

If StringInStr(FileGetAttrib($startDir & "\" & $next), "D") Then

$time = filegettime ($startDir & "\" & $next, 0 , 1)

If $time > 20100901000000 Then

$RFSstring &= $time & " ----- " & $startDir & "\" & $next & "*"

RecursiveFileSearch ($startDir & "\" & $next, $depth + 1)

Endif

Else

;Append filename to master string

$time = filegettime ($startDir & "\" & $next, 0 , 1)

If $time > 20100901000000 Then

$RFSstring &= $time & " ----- " & $startDir & "\" & $next & "*"

Endif

EndIf

WEnd

FileClose($search)

If $depth = 0 Then Return (StringSplit(StringTrimRight($RFSstring, 1), "*"))

EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;==>RecursiveFileSearch

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

Heres how you can sort em

#include <array.au3>

$files = recursivefilesearch ("C:\windows\system32")



_arraydelete ($files , 0)
_arraysort($files)
_arraydisplay ($files)



;;;:::::WEAPON X's - RECURSIVE FILE SEARCH - PULLS FULL DIRECTORY AND NAME:::::::::::::::::::::::::::
Func RecursiveFileSearch ($startDir, $depth = 0)

If $depth = 0 Then Global $RFSstring = ""

$search = FileFindFirstFile($startDir & "\*.*")
If @error Then Return

;Search through all files and folders in directory
While 1
$next = FileFindNextFile($search)
If @error Then ExitLoop

;If folder, recurse
If StringInStr(FileGetAttrib($startDir & "\" & $next), "D") Then
    $time = filegettime ($startDir & "\" & $next, 0 , 1)

$RFSstring &= $time & "  -----  " & $startDir & "\" & $next & "*"
RecursiveFileSearch ($startDir & "\" & $next, $depth + 1)
Else
;Append filename to master string

$time = filegettime ($startDir & "\" & $next, 0 , 1)

$RFSstring &= $time & "  -----  " & $startDir & "\" & $next & "*"
EndIf
WEnd
FileClose($search)

If $depth = 0 Then Return (StringSplit(StringTrimRight($RFSstring, 1), "*"))

EndFunc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;==>RecursiveFileSearch

Scrubbed for everything from september forward::

#include <array.au3>

$files = recursivefilesearch ("C:\windows\system32")

_arraydelete ($files , 0)

_arraysort($files)

_arraydisplay ($files)

;;;:::::WEAPON X's - RECURSIVE FILE SEARCH - PULLS FULL DIRECTORY AND NAME:::::::::::::::::::::::::::

Func RecursiveFileSearch ($startDir, $depth = 0)

If $depth = 0 Then Global $RFSstring = ""

$search = FileFindFirstFile($startDir & "\*.*")

If @error Then Return

;Search through all files and folders in directory

While 1

$next = FileFindNextFile($search)

If @error Then ExitLoop

;If folder, recurse

If StringInStr(FileGetAttrib($startDir & "\" & $next), "D") Then

$time = filegettime ($startDir & "\" & $next, 0 , 1)

If $time > 20100901000000 Then

$RFSstring &= $time & " ----- " & $startDir & "\" & $next & "*"

RecursiveFileSearch ($startDir & "\" & $next, $depth + 1)

Endif

Else

;Append filename to master string

$time = filegettime ($startDir & "\" & $next, 0 , 1)

If $time > 20100901000000 Then

$RFSstring &= $time & " ----- " & $startDir & "\" & $next & "*"

Endif

EndIf

WEnd

FileClose($search)

If $depth = 0 Then Return (StringSplit(StringTrimRight($RFSstring, 1), "*"))

EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;==>RecursiveFileSearch

Thank you for your quick reaction. Your script is almost good, but it is not necesary to search in directories, I need only the directories in one map in the array, not the files in it. I want to copy only the directories which are not older then one month to another directory. Also the files in root of the map must be filtert and copy to that same directory where the directories are copied.

I can't figure it out. I hope you can help me with this.

Thanks!

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