Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete all content except the folder #130

Open
sysoev-dev opened this issue Oct 12, 2020 · 3 comments
Open

Delete all content except the folder #130

sysoev-dev opened this issue Oct 12, 2020 · 3 comments

Comments

@sysoev-dev
Copy link

sysoev-dev commented Oct 12, 2020

Hello! I'm a beginner and I'm setting up a galp, I need to Del deleted all the files in the folder, but except for one folder that is located with these files.

-images (Home folder)
--photo.jpg
--photo.jpg
--photo.jpg
--icons (The folder you don't need to delete "images/icons")

How to write it down correctly? I have tried many options already and all in vain.
return del('app/images/*', { force: true })

@fredgan
Copy link

fredgan commented Oct 20, 2020

Hi Vadim @sysoev-dev , Well, you can read from the README.md

This is the codes:

const del = require('del');

(async () => {
	const deletedFilePaths = await del(['images/*', '!images/icons']);
	console.log('Deleted files:\n', deletedFilePaths.join('\n'));
})();

@itstimetoflow
Copy link

itstimetoflow commented Mar 9, 2021

It's not working for "!images\icons" or "!images\\icons", Windows backslash.

@binyamin
Copy link

@itstimetoflow Hi, see the readme under API.

Note that glob patterns can only contain forward-slashes, not backward-slashes. Windows file paths can use backward-slashes as long as the path does not contain any glob-like characters, otherwise use path.posix.join() instead of path.join().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants