Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/fs/mod.ts>copy

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function copy
import { copy } from "https://deno.land/std@0.220.1/fs/mod.ts";

Copy a file or directory. The directory can have contents. Like cp -r. Requires the --allow-read and --allow-write flag.

Examples

Example 1

import { copy } from "https://deno.land/std@0.220.1/fs/copy.ts";
copy("./foo", "./bar"); // returns a promise

Parameters

src: string | URL

the file/directory path. Note that if src is a directory it will copy everything inside of this directory, not the entire directory itself

dest: string | URL

the destination path. Note that if src is a file, dest cannot be a directory

optional
options: CopyOptions = [UNSUPPORTED]