Tiger Posted April 8, 2007 Posted April 8, 2007 How can I count the files in a directory? My UDFs:- _RegEnumKey
BrettF Posted April 8, 2007 Posted April 8, 2007 Try this: ; Shows the filenames of all files in the current directory. $search = FileFindFirstFile("*.*") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf $i = 0 While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $i = $i + 1 WEnd MsgBox (0, "Files", "There are " &$i&" files and folders in the directory.") ; Close the search handle FileClose($search) Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Hasher Posted April 8, 2007 Posted April 8, 2007 check out _FileListToArray in file.au3 #include <File.au3> _FileListToArray ( $sPath [, $sFilter [, $iFlag]] ) Optional: specifies wheather to return files folders or both $iFlag=0(Default) Return both files and folders $iFlag=1 Return files only <---great filter if you want files only $iFlag=2 Return Folders only The array returned is one-dimensional and is made up as follows: $array[0] = Number of Files\Folders returned <------what you want Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of shhh extensions!
Danny35d Posted April 8, 2007 Posted April 8, 2007 You can also use DirGetSize() function.If you use the extended mode then the array returned from this function is a single dimension array containing the following elements:$array[0] = Size$array[1] = Files count$array[2] = Dirs Count#include <Array.au3> $size = DirGetSize(@DesktopDir, 1) _ArrayDisplay($size, 'Files') AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Tiger Posted April 8, 2007 Author Posted April 8, 2007 Thanks people. I test it today. My UDFs:- _RegEnumKey
hmsSurprise Posted April 8, 2007 Posted April 8, 2007 If looking for all files shouldn't we use '*' instead of '*.*' ?
MrCreatoR Posted April 8, 2007 Posted April 8, 2007 Quote If looking for all files shouldn't we use '*' instead of '*.*' ?I think that using *.* is more “secure”, because when you use *.* it search for all files with any extansion. Reveal hidden contents Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
magician13134 Posted April 8, 2007 Posted April 8, 2007 Yes, but what if you have 'blah' with no extension, several programs create files like that... when installing iPod Linux you need the file called 'start' with no extension... I think that was hmsSurprise's point... Visit Magic Soft Inc. for some of my software
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now