glob#

glob(folder=None, pattern=None, fnmatch=None, abspath=False, nopath=False, filesonly=False, foldersonly=False, recursive=True, aspath=None)#

A shortcut for using glob.glob().

Note that sc.getfilelist() and sc.glob() are aliases of each other.

Parameters:
  • folder (str) – the folder to find files in (default, current)

  • pattern (str) – the pattern to match (default, wildcard); can be excluded if part of the folder

  • fnmatch (str) – optional additional string to filter results by

  • abspath (bool) – whether to return the full path

  • nopath (bool) – whether to return no path

  • filesonly (bool) – whether to only return files (not folders)

  • foldersonly (bool) – whether to only return folders (not files)

  • recursive (bool) – passed to glob.glob() (note: ** is required as the pattern to match all subfolders)

  • aspath (bool) – whether to return Path objects

Returns:

List of files/folders

Examples:

sc.getfilelist() # return all files and folders in current folder
sc.getfilelist('~/temp', '*.py', abspath=True) # return absolute paths of all Python files in ~/temp folder
sc.getfilelist('~/temp/*.py') # Like above
sc.getfilelist(fnmatch='*.py') # Recursively find all files ending in .py
New in version 1.1.0: “aspath” argument
New in version 2.1.0: default pattern of “**”; “fnmatch” argument; default recursive=True