mvdate Modules
Move files based on date.
construct_date_time(file_creation, nesting=None, single=False)
Construct date and time from a file creation date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_creation
|
float
|
Date and time of file creation. |
required |
nesting
|
str
|
Level of nesting to extract, values are 'Y'ear, 'm'onth, 'd'ay, 'H'our, 'M'inutes. Defaults to 'd'ay if not specified. |
None
|
single
|
bool
|
Whether to make target directory a single rather than nested structure. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
Directory structure to create with given level of nesting. |
Source code in mvdate/mvdate.py
create_parser()
Create a parser for reading options.
Returns:
| Type | Description |
|---|---|
ArgumentParser
|
Returns an argument parser. |
Source code in mvdate/mvdate.py
create_target_dir(date_time, destination='./', quiet=True)
Create the target directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date_time
|
str
|
Date/time construct to be created within the destination directory. |
required |
destination
|
str | Path
|
Path where target directory structure is to be created. |
'./'
|
quiet
|
bool
|
Report creation of target directory. |
True
|
Returns:
| Type | Description |
|---|---|
None
|
Does not return anything, simply creates the target directory. |
Source code in mvdate/mvdate.py
find(base='./', ext='jpg')
Find files of a given type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base
|
str | Path
|
Directory to search for files. |
'./'
|
ext
|
str
|
File extension to search for. |
'jpg'
|
Returns:
| Type | Description |
|---|---|
list
|
List of found files. |
Source code in mvdate/mvdate.py
get_file_date(file, method='exif')
Extract created date from file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
Path
|
File to extract created date from. |
required |
method
|
str
|
Date/time extraction method to use, currently supports exif (default), ctime and mtime. |
'exif'
|
Returns:
| Type | Description |
|---|---|
float
|
Returns the date as an elapsed float from origin. |
Source code in mvdate/mvdate.py
main(args=None)
Find and move files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
ArgumentParser
|
Arguments to run the function with. |
None
|
Source code in mvdate/mvdate.py
move_file(source, destination, quiet=True)
Move a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Path
|
Path to the source file. |
required |
destination
|
Path
|
Destination directory. |
required |
quiet
|
bool
|
Suppress logging output. |
True
|
Returns:
| Type | Description |
|---|---|
Path
|
Returns the Path the file is moved to. |