Sign in to follow this  
Followers 0
udik

Getting number of files in a directory

4 posts in this topic

Hi all,

I'm a newbie to this tool and to this site; I found it yesterday night after very long and frustrating time trying to make something work; guys this tool is AMAZING!!! honestly I did not believe anything as good exists, and moreover, free. Once I get my project done I'll find out about the developers and contribute both time and money if needed. Anyway todya is my first day without mami in this classroom; so forgive me for my possibly stupid question.

Is there an easy way to find the number of files of certain type in a directory? while writing this post I'm realizing that I can loop over the files first, and keep the counter for my "real" loop that needs this number. But I was hoping there is something like getFilesCount("c:\bla\*.wav") or something like that.

BTW the reason I need this is becuase for some reason the last iteration on the while(1) loop is not executed, so I figured out I can just call the required logic one more time aftre the loop. Hey there may be a quick fix to what I'm experianceing but I could not find it ...

Thanks much, great work!!

Udi

Share this post


Link to post
Share on other sites



Maybe you can create a hidden window or make a window & hide it like really fast. Dunno just an idea. just change ur folder name those classes are always same

ShellExecute('D:\My Temp folder')

WinWait('My Temp folder')

WinSetState("My Temp folder", "", @SW_HIDE)
Sleep(3000)

$class = 'msctls_statusbar32'
$e = ControlGetText('My Temp folder', "", $class & "1" )    ; localisation

WinSetState("My Temp folder", "", @SW_SHOW)

    
ConsoleWrite($e & @CRLF)

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

First off it's "While 1" not "While(1)"

Sorry, you got me there... You were right... :P

Your looking for this I believe...

_FileListToArray() Lists files and\or folders in a specified path (Similar to using Dir with the /B Switch)

#Include <File.au3>
$Directory = @ScriptDir  ; Dir to check for files
$FileList = _FileListToArray($Directory, "*.wav", 1) ; The *.Wav is a filter... So It will only return WAV files...
MsgBox(0,"There are...",$FileList[0] & " WAV files were found in " & $Directory)

Look that function up, and you will have everything you need.

DirGetSize() Will return a perfect count of files in a Directory, but does not support a filter, such as *.wav

Edited by BinaryBrother

Share this post


Link to post
Share on other sites

Check out the extended mode of DirGetSize() in the help file.

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