DeleteFiles icon indicating copy to clipboard operation
DeleteFiles copied to clipboard

Delete Folder with symlink

Open Ndrou opened this issue 10 years ago • 6 comments

Consider this file architecture :

-- root folder
---- subroot folder 1
---- subroot folder 2 (symlink)

Subroot folder 2 is a symlink created with the command : mklink /D myfolder c:/mypath

And when I delete the root folder, the application delete files inside subroot folder 2.

It should only remove the symbolic link ! This is very dangerous !

Ndrou avatar Sep 03 '15 06:09 Ndrou

But won't this only delete if there are no files in subroot folder 2?

RickStrahl avatar Sep 05 '15 19:09 RickStrahl

In fact, your application is focused on files deletion, not really on folders deletion, i didn't understand that, sorry.

The -f parameter deletes empty folders, so i understand your perspective.

A new option would be welcome for enabling symlinks deletion that will not delete the files under the symlink

Ndrou avatar Sep 08 '15 17:09 Ndrou

Can you clarify what it is you actually want to do? The scenario we usually have is that we delete files and only delete folders if you provide the -d switch to remove them if htey are empty.

To be honest I haven't checked into how a SymLink behaves in this scenario, but what do you expect should happen? I would expect the behavior to be the same as a regular folder - ie. delete the files down the line, and then remove the folder if it's empty (not sure if that would work though - I believe removing a symlink will fail silently).

RickStrahl avatar Sep 08 '15 19:09 RickStrahl

The scenario that I wish would be as follows, below my file architecture:

---- folder 1
------ index.js
------ node_modules
-------- folder 2 (symlink)
------ (...)
---- folder 2
------ index.js
------ node_modules
------ (...)
---- folder 3 <-- folder to delete
------ index.js
------ node_modules
-------- folder 1 (symlink) <-- should only delete this symlink but not files inside
-------- folder 2 (symlink) <-- should only delete this symlink but not files inside
-------- folder 4
-------- (...)

Your tool is very useful to remove nodes_modules because under Windows path names are often too long.

However in this case, if I delete folder 3, I don't want the application deletes the files or folders inside folder 1 and 2, but only their symlinks.

Currently, I must not forget to delete them manually before running your application, otherwise it is the drama, your application deletes the contents of these folders...

Ndrou avatar Sep 09 '15 06:09 Ndrou

Yeah I see your scenario.

The only way this logic would make sense is if:

Wildcard is . Folder is a symlink If it is delete the symlink only (not the files)

Otherwise - ignore symlink folder completely - don't recurse into it.

RickStrahl avatar Sep 09 '15 07:09 RickStrahl

:+1: agree with the 2 ways

Ndrou avatar Sep 09 '15 07:09 Ndrou