move
Bases: FileOperation
An operation to move files from a source directory to a target directory.
This class identifies files that match specific patterns and relocates them to the destination directory. It includes a safety check to prevent moving a file into the same directory where it is already located.
Source code in file_operations/move.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
add_arguments(settings, parser)
staticmethod
Adds the destination argument to the command-line interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
AppSettings
|
The global settings object for default values. |
required |
parser
|
ArgumentParser
|
The CLI parser to which arguments are added. |
required |
Source code in file_operations/move.py
17 18 19 20 21 22 23 24 25 26 | |
do_task()
Iterates through the collected files and moves them to the target directory.
The method checks if each item is a file and ensures the target path is different from the source path. It uses 'shutil.move' for the operation and logs the results or any errors that occur.
Source code in file_operations/move.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |