GeoEco.DataManagement.Directories.Directory.FindAndMove
- classmethod Directory.FindAndMove(inputDirectory, outputDirectory, wildcard='*', searchTree=False, mustBeEmpty=False, mustNotBeEmpty=False, minDateCreated=None, maxDateCreated=None, minDateModified=None, maxDateModified=None, destinationDirectoryPythonExpression='os.path.join(rootDestination, sourceDirectory[len(directoryToSearch)+1:])', modulesToImport=['os.path'], skipExisting=False)
Finds and moves directories in a directory.
- Parameters:
inputDirectory (
str) – Directory to search. Minimum length꞉ 1. Must exist.outputDirectory (
str) – Directory to receive the directories. Minimum length꞉ 1.wildcard (
str, optional) –UNIX-style “glob” wildcard expression specifying the directories to find.
The glob syntax supports the following patterns:
?- matches any single character*- matches zero or more characters[seq]- matches any single character inseq[!seq]- matches any single character not inseq
seqis one or more characters, such asabc. You may specify character ranges using a dash. For example,a-z0-9specifies all of the characters in the English alphabet and the decimal digits0through9.You may specify subdirectories in the glob expression. For example, the expression
cruise*/sst*will find all paths beginning with sst that are contained in directories beginning with cruise.The operating system determines whether
/or\is used as the directory separator. On Windows, both will work. On Linux,/must be used.The operating system determines if matching is case sensitive. On Windows, matching is case-insensitive. On Linux, matching is case-sensitive.
Minimum length꞉ 1.
searchTree (
bool, optional) – If True, subdirectories will be searched.mustBeEmpty (
bool, optional) – If True, only empty directories will be found.mustNotBeEmpty (
bool, optional) – If True, only non-empty directories will be found.minDateCreated (
datetime, optional) – Minimum creation date, in the local time zone, of the directories to find, as reported by the operating system. If provided, only directories that were created on or after this date will be found. You may provide a date with or without a time. If you do not provide a time, it is assumed to be midnight.maxDateCreated (
datetime, optional) – Maximum creation date, in the local time zone, of the directories to find, as reported by the operating system. If provided, only directories that were created on or before this date will be found. You may provide a date with or without a time. If you do not provide a time, it is assumed to be midnight.minDateModified (
datetime, optional) – Minimum modification date, in the local time zone, of the directories to find, as reported by the operating system. If provided, only directories that were modified on or after this date will be found. You may provide a date with or without a time. If you do not provide a time, it is assumed to be midnight.maxDateModified (
datetime, optional) – Maximum modification date, in the local time zone, of the directories to find, as reported by the operating system. If provided, only directories that were modified on or before this date will be found. You may provide a date with or without a time. If you do not provide a time, it is assumed to be midnight.destinationDirectoryPythonExpression (
str, optional) –Python expression used to calculate the absolute path of the destination directory. The expression may be any Python statement appropriate for passing to the eval function and must return a Unicode string. The expression may reference the following variables:
directoryToSearch- the value provided for the directory to search parameterrootDestination- the value provided for the root destination directory parametersourceDirectory- the absolute path of the source directory
The default expression,
os.path.join(rootDestination, sourceDirectory[len(directoryToSearch)+1:]), copies the directory to the root destination directory to the same relative location as it appears in the directory to search. The destination directory path is calculated by stripping the directory to search from the source directory and replacing it with the root destination directory.For more information on Python syntax, please see the Python documentation.
Minimum length꞉ 1.
modulesToImport (
listofstr, optional) – Python modules to import prior to evaluating the expression. If you need to access Python functions or classes that are provided by a module rather than being built-in to the interpreter, list the module here. For example, to be able to use thedatetimeclass in your expression, list thedatetimemodule here. In your expression, you must refer to the class using its fully-qualified name,datetime.datetime.skipExisting (
bool, optional) – If True, moving will be skipped for destination directories that already exist.
- Returns:
Directory to receive the directories.
- Return type: