Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If a folder is not empty, do something
#7
I see a couple issues with this function 
#1. if folder contains subfolders and has files doesn't detect it.
#2. dir is an obsolete function
   

Maybe something like this would be better

Function IsFolderEmpty
Code:
Copy      Help
function# str'folderpath

;checks folder and its subfolders(if they exist) to see if it's empty or not
;
;REMARKS
;;folderpath- must end with a \ and be top level of folder to check(subfolders are automatically checked)
;;folderpath example- $documents$\test folder\   (test folder is the desired(TopLevel) folder to check)
;;Returns: 1 if folder is not empty, 0 if  folder is empty or If folder doesn't exist

;EXAMPLES
;if IsFolderEmpty("$documents$\test folder\")
,;out "not empty"
;if !IsFolderEmpty("$documents$\test folder\")
,;out "empty"
;int ReturnValue=IsFolderEmpty("$documents$\test folder\")
;out ReturnValue

str folder.getpath(folderpath "\*")
Dir d
foreach(d folder FE_Dir 0|4|32)
,if d.dir("*.*" 0)
,,ret 1
ret 0
Macro MacroExample
Code:
Copy      Help
if IsFolderEmpty("$documents$\test folder\")
,out "not empty"
 this is not  the only solution 
Feel free to correct or improve on this function or offer different solutions


Messages In This Thread
RE: If a folder is not empty, do something - by Kevin - 07-16-2018, 06:51 PM

Forum Jump:


Users browsing this thread: 5 Guest(s)