Autohotkey Count Number of Files/Folders in a Directory
- Joel Lipman
- AutoHotkey
- Hits: 12945
So this is an article to list methods of retrieving the number of files in a folder/directory.
Why?
Why can't we just use a loop and file pattern native to the Autohotkey programming language:
UserFolder:="C:" -- UserFolder := RegExReplace( MyInputField, "\\$") ; gets rid of trailing slash if required -- Method #1 count := 0 Loop, %UserFolder%\*.*, 0, 1 count++ -- note for future use: ; if A_LoopFileAttrib contains H,R,S ; continue
- UserFolder:="C:"
- -- UserFolder := RegExReplace( MyInputField, "\\$") ; gets rid of trailing slash if required
- -- Method #1
- count := 0
- Loop, %UserFolder%\*.*, 0, 1
- count++
- -- note for future use:
- ; if A_LoopFileAttrib contains H,R,S
- ; continue