Skip to main content

@std/fs@1.0.6
Built and signed on GitHub Actions

Helpers for working with the file system

This package works with Deno
This package works with Deno
JSR Score
94%
Published
a week ago (1.0.6)
function move
move(
src: string | URL,
dest: string | URL,
options?: MoveOptions,
): Promise<void>

Asynchronously moves a file or directory (along with its contents).

Requires --allow-read and --allow-write permissions.

Examples

Basic usage

import { move } from "@std/fs/move";

await move("./foo", "./bar");

This will move the file or directory at ./foo to ./bar without overwriting.

Overwriting

import { move } from "@std/fs/move";

await move("./foo", "./bar", { overwrite: true });

This will move the file or directory at ./foo to ./bar, overwriting ./bar if it already exists.

Parameters

src: string | URL

The source file or directory as a string or URL.

dest: string | URL

The destination file or directory as a string or URL.

optional
options: MoveOptions

Options for the move operation.

Return Type

Promise<void>

A void promise that resolves once the operation completes.

Throws

Deno.errors.AlreadyExists

If dest already exists and options.overwrite is false.

Deno.errors.NotSupported

If src is a sub-directory of dest.

See

Add Package

deno add jsr:@std/fs

Import symbol

import { move } from "@std/fs";

---- OR ----

Import directly with a jsr specifier

import { move } from "jsr:@std/fs";