https://github.com/noahweasley/clean-sweep
A Node JS library that delete all empty files and folders in a target directory.
https://github.com/noahweasley/clean-sweep
clean directories directory empty erase file files filesystem sweep
Last synced: 22 days ago
JSON representation
A Node JS library that delete all empty files and folders in a target directory.
- Host: GitHub
- URL: https://github.com/noahweasley/clean-sweep
- Owner: noahweasley
- License: mit
- Created: 2023-07-26T21:37:28.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-12T17:25:54.000Z (11 months ago)
- Last Synced: 2025-04-03T01:35:38.204Z (25 days ago)
- Topics: clean, directories, directory, empty, erase, file, files, filesystem, sweep
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/clean-sweep
- Size: 46.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Clean Sweep
  
> Delete all files and folders in a target directory, according to a threshHold file size.
## How to Use
### Installation (as a script)
```bash
npm install clean-sweep -g
```### Usage (as a script)
```bash
clean-sweep -v -t
# OR
csw -v -t```
- The first argument is the path to the directory in which the operation would be performed, and is required!
- The remaining are optional### Optional Parameters
-v: prints out the operation of the sweep function to console if specified
-t: specifies the threshold. Threshold here is the file size(in bytes), in which with, files with sizes below this threshold, are deleted### Example
```bash
clean-sweep ./music
clean-sweep ./music -v
clean-sweep ./music -t 200
# OR
csw ./music
csw ./music -v
csw ./music -t 200
```### Installation (in code)
```bash
npm install clean-sweep --save
```### Usage (in code, synchronously)
```javascript
const cleanSweep = require("clean-sweep");
const fileDirectory = "";try {
cleanSweep.sweepSync(fileDirectory, {
/* specify if operation info should be printed to console, defaults to false */
verbose: true,
/* all files with size(in byte) below this thresh hold are deleted, defaults to 0 */
threshHold: 200
});
} catch (err) {
if (err.code == "ENOENT") {
console.error("Directory does not exist");
} else {
console.error(err.message);
}
}
```### Usage (in code, asynchronously)
```javascript
const cleanSweep = require("clean-sweep").promises;
const fileDirectory = "";(async function () {
try {
await cleanSweep.sweep(fileDirectory, {
/* specify if operation info should be printed to console, defaults to false */
verbose: true,
/* all files with size(in byte) below this thresh hold are deleted, defaults to 0 */
threshHold: 200
});
} catch (err) {
if (err.code == "ENOENT") {
console.error("Directory does not exist");
} else {
console.error(err.message);
}
}
})();
```