View Single Post
Old 4th January 2018, 09:03   #1
Coby
Junior Member
 
Join Date: Feb 2016
Posts: 48
How can I determine how many files I am in a folder?

Hello!
I used the Call SearchFiles method but the result was not the one I wanted.
E.g:
When I searched files from two different folders,
The first folder resulted in a certain number of files and the second one continued the remaining count in the first folder.
How can I determine the exact number of files for each folder.

PHP Code:
Name "Search File or Folder"
OutFile "SearchFile.exe"

Function SearchFile

  Pop 
$1
  Pop 
$0

  StrCpy 
$$1 1 -1
  StrCmp 
$+2
  StrCpy 
$$-1

  StrCpy 
$$0 1 -1
  StrCmp 
$\ +2
  StrCpy 
$"$0\"

  FindFirst $2 $3 "
$0$1"

FindNextFile:

  StrCmp $3 "" NoFiles
  StrCpy $5 "
$5$0$3|"
  IntOp $4 $4 + 1

  DetailPrint "
$4ş found file: $0$3"

  FindNext $2 $3
  Goto FindNextFile

  NoFiles:

  FindClose $2

  FindFirst $2 $3 "
$0*."

  Push $6

  StrCpy $6 $0 "" 1
  StrCmp $6 "
:\" +2

  FindNext $2 $3

  Pop $6

FindNextSubfolder:

  FindNext $2 $3
  StrCmp $3 "" NoSubfolders

  IfFileExists "
$0$3\" FindNextSubfolder

  Push $0
  Push $1
  Push $2
  Push $3

  Push "
$0$3\"
  Push $1
  Call SearchFile

  Pop $3
  Pop $2
  Pop $1
  Pop $0

  IntOp $4 $4 + 
$R0

  Goto FindNextSubfolder

NoSubfolders:

  FindClose $2

FunctionEnd

var /GLOBAL LOGDIR

Section SearchFile

  Strcpy 
$LOGDIR "$EXEDIR\Log"
  CreateDirectory "
$LOGDIR"

  FileOpen $0 "
$LOGDIR\Log.ini" w
  FileWrite $0 "
[Log]"
  FileClose $0

  Push "
c:\"
  Push "
Temp\*.*"
  Call SearchFile

  Strcpy 
$LOGDIR "$EXEDIR\Log"
  WriteINIStr "
$LOGDIR\Log.ini" "Log" "Temp_Files" "Total Files: $$5"

  Push "
c:\"
  Push "
Google\*.*"
  Call SearchFile

  Strcpy 
$LOGDIR "$EXEDIR\Log"
  WriteINIStr "
$LOGDIR\Log.ini" "Log" "Google_Files" "Total Files: $$5"

SectionEnd 
Coby is offline   Reply With Quote