sciris.sc_fileio.getfilelist

getfilelist(folder=None, pattern=None, abspath=False, nopath=False, filesonly=False, foldersonly=False, recursive=False, aspath=None)[source]

A shortcut for using glob.

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

  • 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()

  • 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

New in version 1.1.0: “aspath” argument