 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
retrievea Guest
|
Posted: Thu Apr 19, 2007 10:28 am Post subject: retrieve the number of files in a folder |
|
|
Sorry to ask something so basic....
how to retrieve the number of files in a folder?
| Code: | dir = c:\pasda
FileRead Filex, %dir%
StringReplace Filex, Filex, `n, `n, All UseErrorLevel
MsgBox Total number of lines is %ErrorLevel% |
Thanks in advance. |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Thu Apr 19, 2007 10:33 am Post subject: |
|
|
| Code: | Folder = c:\myfolder
Loop, %Folder%\*.*
NumFiles++
MsgBox %NumFiles% files in %Folder% | Not tested. |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3842 Location: Bremen, Germany
|
Posted: Thu Apr 19, 2007 10:33 am Post subject: |
|
|
AFAIK, you need to loop,Filepattern through the path and count. I do not know a shorter way.
Edit: Hi Bobo. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Thu Apr 19, 2007 10:36 am Post subject: |
|
|
Hi Toralf (Meister deutscher AHKHardcoreProjekte)  |
|
| Back to top |
|
 |
retrievea Guest
|
Posted: Thu Apr 19, 2007 11:06 am Post subject: |
|
|
Thank you very much!  |
|
| Back to top |
|
 |
Markus M.
Joined: 17 Apr 2007 Posts: 14 Location: Stuttgart (Ger)
|
Posted: Thu Apr 19, 2007 11:41 am Post subject: |
|
|
this one reads the dir recursive, counting files folders and size:
| Code: |
#NoEnv
SendMode Input
gui,add,text,, Please wait...
Gui, Show,w220 h50 ,Please wait
source=%A_WinDir%
SetBatchLines, -1
Loop, %source%\*, 1, 1
{
IfInString, A_LoopFileAttrib, D
NumDirs += 1
else
NumFiles += 1
FolderSize += %A_LoopFileSize%
}
gui,destroy
Gui, Add, Text, xm y+20 , Files:
Gui, Add, Text, xp+80 w60 , %NumFiles%
Gui, Add, Text, xs, Directories:
Gui, Add, Text, xp+80 w60 , %NumDirs%
Gui, Add, Text, xm, Size:
SizeMB := Round(FolderSize/1000000 , 2)
Gui, Add, Text, xp+80 w60 , %SizeMB% MB
Gui, Add, Button, gButtonEND Default w100 , Close
Gui, Show, ,Dir content
return
ButtonEND:
guiescape:
GuiClose:
ExitApp
|
this is part of a script i working on
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|