KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utility Method for Deleting Invisible Files
PRODUCT: 4D | VERSION: 19 R | PLATFORM: Mac & Win
Published On: May 24, 2022

Invisible files are often used to control the display of the items in a given folder. Because they are hidden from the user's view, deleting them can only be done programmatically.

The following method is a utility method that removes all invisible files (all level) from a given folder.

// Method: removeInvisibleFiles

#DECLARE($folder_t : Text)

var $i : Integer
var $path_t : Text
var $file_o : Object

If (Count parameters>=1)
  ARRAY TEXT($file_at; 0)
  DOCUMENT LIST($folder_t; $file_at; Recursive parsing+Absolute path)
  For ($i; 1; Size of array($file_at))
    $path_t:=Convert path system to POSIX($file_at{$i})
    $file_o:=File($path_t)
    If ($file_o.hidden)
      $file_o.delete()
    End if
  End for
End if