Skip to content

File Operations

Copy, move, and delete files.

3 modules

ModuleDescription
複製檔案複製檔案到另一個位置
刪除檔案從檔案系統刪除檔案
移動檔案移動或重新命名檔案

Modules

複製檔案

file.copy

複製檔案到另一個位置

Parameters:

NameTypeRequiredDefaultDescription
sourcestringYes-Path to the source file
destinationstringYes-Path where the file will be saved
overwritebooleanNoFalseReplace the file if it already exists

Output:

FieldTypeDescription
copiedboolean是否成功複製
sourcestring來源路徑
destinationstring目的地路徑
sizenumber檔案大小

Example: Backup file

yaml
source: data/important.csv
destination: backup/important.csv
overwrite: true

Example: Duplicate configuration

yaml
source: config.yaml
destination: config.backup.yaml

刪除檔案

file.delete

從檔案系統刪除檔案

Parameters:

NameTypeRequiredDefaultDescription
pathstringYes-Path to the file
ignore_missingbooleanNoFalseSkip without error if file does not exist

Output:

FieldTypeDescription
deletedboolean是否成功刪除
file_pathstring已刪除的檔案路徑

Example: Delete temporary file

yaml
file_path: /tmp/temp.txt
ignore_missing: true

Example: Delete log file

yaml
file_path: logs/app.log

移動檔案

file.move

移動或重新命名檔案

Parameters:

NameTypeRequiredDefaultDescription
sourcestringYes-Path to the source file
destinationstringYes-Path where the file will be saved

Output:

FieldTypeDescription
movedboolean是否成功移動
sourcestring來源路徑
destinationstring目的地路徑

Example: Move file to archive

yaml
source: data/input.csv
destination: archive/input_2024.csv

Example: Rename file

yaml
source: report.txt
destination: report_final.txt

Released under the Apache 2.0 License.