Jump to content

Recommended Posts

Posted

$search=FilefindFirstFile("C:\dir\*.txt")

while 1

$file = FileFindNextFile($search)

if @error then exitloop

$countfiles += 1

wend

fileclose($search)

this counts all *.txt in c:\dir

SYS 64738

Posted

No offence but this is a kind of hilarious question from someone with your kind of nick :P

Anyhow, modify the sample provided in the help file for FileFindNextFile and you should be set. If you want to filter out the folders you could do so by checking the result from FileGetAttrib.

Happy coding :)

Posted

;change the working directory
FileChangeDir( ".\temp" )

;get the first file
$search = FileFindFirstFile( "*.*" )

If $search = -1 Then
    MsgBox( 0, "ERROR!", "There are no files or could not connect to remote directory" )
EndIf

Dim $fileCount = 0

While 1
    $file = FileFindNextFile( $search )
    
    If @error Then
        ExitLoop
    EndIf
    If StringInStr( FileGetAttrib( $file ), "D" ) == 0 Then
        $fileCount += 1
    EndIf
WEnd

MsgBox( 0, "File Count", "Found " & $fileCount & " files." )

_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Posted

Hi,

Is it possible to count the number of files that are in a specified directory?

Thanks!

Look at the extended mode of DirGetSize().

$retArray = DirGetSize("C:\",1)

$nFiles = $retArray[1]
$nDirs = $retArray[2]

BTW: Think about error checking!! See help file sample.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

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
×
×
  • Create New...