Jump to content

Array Help


AndyB
 Share

Recommended Posts

Hello.

I'm would appreciate it if somebody help me.

What i'm going to do:

I have some number of directories, i need to check size of this directories and write result to any file,

then i need start to calculate size of 1+2+3+....+x directories until I'm received total size max to 4.4 GB

(I need this for burn in further this directories on DVD disk), write names of calculated directories to file and start new calculation from next directory etc.

I'm started creating AutoIt script (below), i receive sizes of all directories but i don't now how to do calculating ?!

Thanks to all.

Andy

_______________________________________________

#include <Array.au3>

$path = "D:\Test"

FileChangeDir($path)

$search = FileFindFirstFile("*.*")

If $search = -1 Then

MsgBox(0, "Error", "No files/directories matched the search pattern")

Exit

EndIf

While 1

$filename = FileFindNextFile($search)

If @error Then ExitLoop

If StringInStr(FileGetAttrib($filename), "D") Then

$outDirName = $filename

$outDirSz = DirGetSize($path & "\" & $filename)

$outDirSz = Round($outDirSz / 1073741824, 2)

If $filename > ".." Then

IniWrite("D:\myfile.ini", $outDirName, "Size", $outDirSz)

Endif

If $filename > ".." Then

$var = IniRead("D:\myfile.ini", $outDirName, "Size", "NotFound")

Dim $avArray

$avArray = _ArrayCreate($var)

_ArrayDisplay( $avArray, "Array created with _ArrayCreate" )

Endif

EndIf

WEnd

________________________________________________________

Link to comment
Share on other sites

Just a Quick rehash of your Code

;#include <Array.au3>
$path = "c:\downloads"
FileChangeDir($path)
$search = FileFindFirstFile("*.*")
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

$SzeCount = 0

While 1
    $filename = FileFindNextFile($search)
    If @error Then ExitLoop
    
    If StringInStr(FileGetAttrib($filename), "D") Then
        $outDirName = $filename
        $outDirSz = DirGetSize($path & "\" & $filename)
        $SzeCount += $outDirSz

        If $filename > ".." Then
            IniWrite("c:\myfile.ini", $outDirName, "Size", Round(($SzeCount / 1024 / 1024),2) & "MB")
                                                  $SzeCount = 0 
            $var = IniRead("c:\myfile.ini", $outDirName, "Size", "NotFound")

;           Dim $avArray
;           $avArray = _ArrayCreate ($var)
;           _ArrayDisplay($avArray, "Array created with _ArrayCreate")
        EndIf
    EndIf   
        
WEnd

Hope this gets you on track

HardCopy

Edited by HardCopy

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Link to comment
Share on other sites

Thanks, but i receive an error on line

$SzeCount += $outDirSz

Error: Expected a "=" operator in assigment statement

Andy

Ok if you none beta try

$SzeCount = $SzeCount + $outDirSz

HardCopy

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

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