Are you still worried about slow file deletion? The powerful tool dlf is here to help you. As a front-end developer, the most common one is node_modules. If there are many dependencies, it is okay to delete them on osx system, but it will be in trouble for Windows users. This article shares a command line file and folder deletion tool.
This tool uses node.js, so make sure your computer has node.js installed first.
npm install -g dlf
Delete file
dlf file
Delete folder
dlf directory
Welcome to fork or star
Mainly uses the node.js file operation method
fs.existsSync(path) Returns true if the file exists, otherwise returns false
fs.statSync(dir) Returns the related attributes of dir
fs.readdirSync(dir) Returns a file that does not include '.' and '..' array of file names
fs.unlinkSync(file) Delete file
fs.rmdirSync(dir) Delete folder
if( fs.existsSync(dir) ) { if(fs.statSync(dir).isDirectory()) { files = fs.readdirSync(dir); files.forEach(function(file,index){ var curPath = path.join(dir,file); if(fs.statSync(curPath).isDirectory()) { run(curPath); } else { fs.unlinkSync(curPath); } }); fs.rmdirSync(dir); } else { fs.unlinkSync(dir); } }
1. Prompt to confirm before deleting
2.Support deletion filtering, you can Filter out the ones you don’t want to delete
3. Support deleting files that only have administrator permissions
The above is the detailed content of How can I quickly delete files?. For more information, please follow other related articles on the PHP Chinese website!