folder-clean
Analyzes and potentially deletes all files and folders which are older than a given date. The analyze phase has been seperated from the deletion phase. This has the benefit that we can first display the results before actually deleting them.
Getting Started
First we'll analyze all items contained in a given folder. Note that this does not delete anything yet. In this example we additionally mark empty folders as deletable.
const markEmptyFoldersAsDeletable analyzeFolderRecursive executeActions } = const join = const actions =
Where actions
contains something like the following.
itemType: SymbolFILE actionType: SymbolDELETE path: '~/absolute/path/to/old.txt' // this would have gotten deleted if we didn't mark // empty folders. itemType: SymbolEMPTY_DIR actionType: SymbolDELETE path: '~/absolute/path/to/empty-folder' itemType: SymbolFILE actionType: SymbolDELETE path: '~/absolute/path/to/sub-folder/old.txt' itemType: SymbolFILE actionType: SymbolRETAIN path: '~/absolute/path/to/new.txt' } itemType: SymbolFILE actionType: SymbolRETAIN path: '~/absolute/path/to/sub-folder/new.txt' itemType: SymbolDIR actionType: SymbolRETAIN path: '~/absolute/path/to/sub-folder'
After that, execute each given action.
await
Installation
> npm install folder-clean
(or)
> yarn add folder-clean