Spaces:
Paused
Paused
Download src/utils/filesystem/deleteAllFilesWith.mts from jbilcke-hf/VideoChain-API: direct link, hf CLI and curl.
- Browser
- Download file 424 Bytes
-
https://huggingface.co/spaces/jbilcke-hf/VideoChain-API/resolve/cd4ee95e1e76fb32012ff8216dcaad5839176a8a/src/utils/filesystem/deleteAllFilesWith.mts
- Command line
-
hf download hf://spaces/jbilcke-hf/VideoChain-API@cd4ee95e1e76fb32012ff8216dcaad5839176a8a/src/utils/filesystem/deleteAllFilesWith.mts
-
curl -L -o deleteAllFilesWith.mts https://huggingface.co/spaces/jbilcke-hf/VideoChain-API/resolve/cd4ee95e1e76fb32012ff8216dcaad5839176a8a/src/utils/filesystem/deleteAllFilesWith.mts
424 Bytes
| import { promises as fs } from "node:fs" | |
| import path from "node:path" | |
| export const deleteFilesWithName = async (dir: string, name: string) => { | |
| for (const file of await fs.readdir(dir)) { | |
| if (file.includes(name)) { | |
| const filePath = path.join(dir, file) | |
| try { | |
| await fs.unlink(filePath) | |
| } catch (err) { | |
| console.error(`failed to unlink file in ${filePath}: ${err}`) | |
| } | |
| } | |
| } | |
| } | |