Garry's Mod Wiki

Revision Difference

file.Find#517600

<function name="Find" parent="file" type="libraryfunc"> <description>Returns a list of files and directories inside a single folder.</description> <realm>Shared and Menu</realm> <args> <arg name="name" type="string">The wildcard to search for. &quot;models/*.mdl&quot; will list .mdl files in the models/ folder.</arg> <arg name="path" type="string">The path to look for the files and directories in. See [this list](/gmod/File_Search_Paths) for a list of valid paths.</arg> <arg name="path" type="string">The path to look for the files and directories in. See <page text="this list">File_Search_Paths</page> for a list of valid paths.</arg> <arg name="sorting" type="string" default="nameasc">The sorting to be used, optional.&#xA;&#xA;* &quot;nameasc&quot; sort the files ascending by name&#xA;* &quot;namedesc&quot; sort the files descending by name&#xA;* &quot;dateasc&quot; sort the files ascending by date&#xA;* &quot;datedesc&quot; sort the files descending by date</arg> </args> <rets> <ret name="" type="table">A table of found files, or nil if the path is invalid</ret> <ret name="" type="table">A table of found directories, or nil if the path is invalid</ret> </rets> </function> <example> <description>Prints the first file and the first directory in the `data` folder.</description> <code> local files, directories = file.Find("*", "DATA") print( "File: " .. files[1], "Folder: " .. directories[1] ) </code> <output> &amp;lt;br /&amp;gt; File: helloworld.txt&amp;lt;br /&amp;gt; Folder: ctp </output> </example>