On this page
@std/fs
Overview Jump to heading
Helpers for working with the filesystem.
import { ensureFile, copy, ensureDir, move } from "@std/fs";
await ensureFile("example.txt");
await copy("example.txt", "example_copy.txt");
await ensureDir("subdir");
await move("example_copy.txt", "subdir/example_copy.txt");
Add to your project Jump to heading
deno add jsr:@std/fs
Why use @std/fs? Jump to heading
Reach for it when you want higher-level filesystem operations (such as ensuring files/dirs, copying, moving, walking directories) than the bare Deno APIs.
Examples Jump to heading
import { ensureDir, expandGlob, walk } from "@std/fs";
await ensureDir("./out/assets");
for await (const entry of expandGlob("src/**/*.{ts,tsx}")) {
console.log(entry.path);
}
for await (
const f of walk("./content", { includeDirs: false, exts: [".md"] })
) {
console.log(f.path);
}
Tips Jump to heading
- Most helpers are async, don’t forget the
await
! - Combine with
@std/path
to build cross-platform paths. - Use
copy
withoverwrite: true
explicitly when replacing files.