参数
fromstring必填移动什么。 文件或文件夹 。
tostring必填其去向。 它的父文件夹是创建的 。
// Rename
await pc.files.move("notes.md", "Launch plan/notes.md");
// Move a whole folder
await pc.files.move("Launch plan", "Archive/2026/Launch plan");
// { name: "Launch plan", path: "Archive/2026/Launch plan", type: "folder", … }# Rename
pc.files.move("notes.md", "Launch plan/notes.md")
# Move a whole folder
pc.files.move("Launch plan", "Archive/2026/Launch plan")
# {"path": "Archive/2026/Launch plan"}拒绝而不是取代
已经上升的目的地 path_exists。没有移动,没有丢失, 和决定如何 如何处理碰撞 与你。
import { IaGenifyError } from "iagenify";
async function moveAside(files, from, to) {
try {
return await files.move(from, to);
} catch (err) {
if (err instanceof IaGenifyError && err.code === "path_exists") {
const stamp = new Date().toISOString().slice(0, 10);
return files.move(from, to.replace(/(\.[^.]+)?$/, ` (${stamp})$1`));
}
throw err;
}
}import re
from datetime import date
def move_aside(files, source, destination):
if (files.root / destination).exists():
stamp = date.today().isoformat()
destination = re.sub(r"(\.[^.]+)?$", lambda m: f" ({stamp}){m.group(1) or ''}", destination, count=1)
return files.move(source, destination)文件夹不能在内部移动
move("Work", "Work/old") 拒绝拒绝时 invalid_path,在任何被触碰之前。将操作在中途或循环失败的文件系统左侧。
这就是如何建造回收箱的
移动到点点文件夹是您可以撤销的删除
隐藏条目不在列表() 中, 所以移动某些在. trash / 下的东西<timestamp>/ 保存每个字节时将其从视图中删除。这正是该代理删除工具的作用,您也可以这样做。
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
await pc.files.move("Launch plan/draft.md", `.trash/${stamp}/Launch plan/draft.md`);from datetime import datetime, timezone
stamp = datetime.now(timezone.utc).isoformat().replace(":", "-").replace(".", "-")
pc.files.move("Launch plan/draft.md", f".trash/{stamp}/Launch plan/draft.md")错误
| 代码 | 状态 | 触发条件 |
|---|---|---|
| path_not_found | 404 | 什么都没有 from. |
| path_exists | 409 | to 被拍摄。 |
| invalid_path | 400 | 绝对的,在工作空间之外,根,或者一个文件夹本身。 |
| local_files_require_node | 400 | 运行环境没有文件系统。 |
| storage_not_on_this_machine | 409 | 另一台电脑的储藏室 |