Anyway of deleting containing folder with a right click on Vista?
October 20, 2008 12:53 PM   Subscribe

I have re-organised my Vista PC to use searches instead of the usual folder hierachy in Explorer to navigate the file system. What I am looking for is a way to right click on a file and delete the containing folder, does anyone know of a registry hack or software which will let me do this?
posted by dazzle to Computers & Internet (12 answers total)
 
Your question is a little vague, are you trying to:

1) Delete the folder containing the file along with all its contents?
2) Move the contents of the folder up one directory level and then get rid of the (now empty) folder?

Your description of the right-click option you want sounds more like 1, but the explanation you prefaced it with makes it sound like 2 would be more in line with the scheme you're trying to enact.

Your re-organization sounds interesting, but be very careful about wiping out folders in any are that's not designed to hold general user-created documents. Many things in Windows are path-dependent and will stop working if the directory structure is changed or destroyed.
posted by contraption at 1:32 PM on October 20, 2008


Response by poster: What I am trying to do is delete the folder containing the file along with all its contents using a right click.
My re-organisation only involves how I use my home folder but it should mean I don't need to 'see' the rest of Windows.
posted by dazzle at 2:03 PM on October 20, 2008


But if you delete the folder containing the file, then the file will be gone, and you won't be able to search for it either...

...I think we need a little more info.
posted by blue_wardrobe at 2:10 PM on October 20, 2008


Response by poster: Let's say I donwload a zip file which contains software, I unzip the zip file which contains an exe and, possibly, other files. In my search for downloaded files I see the exe only, I run the software, decide I don't want to keep it and so wish to delete the zip file, the exe, any other files which may be there also and the folder which the exe was unzipped into. I never actually see the folder. I do not want the exe or any other files which were also unzipped or the containing folder.
posted by dazzle at 2:26 PM on October 20, 2008


Ah, ok.

I accomplish what you want to do in a two step way. I delete the files I don't want or relocate the ones I do.

Then I use a utility called Remove Empty Directories that I run on my profile. I do this about once a week. It is set up to treat folders as empty even if they contain for instance, thumbs.db, desktop.ini, etc.

I can right click somewhere and invoke it on all folders below that point.

www.jonasjohn.de
posted by blue_wardrobe at 3:39 PM on October 20, 2008


Best answer: If you just need a convenient way to accomplish this action and it doesn't specifically have to be a right-click, you could just save this

rmdir /s "%~dp1"

to your desktop as delete-me-and-my-folder.cmd. Then, the containing folder of anything you drag and drop onto it will be deleted. If you don't want to be prompted whether you're sure (dangerous - very easy to delete your entire Desktop or Documents folder by mistake) then include a /q right after the /s.
posted by flabdablet at 5:38 PM on October 20, 2008


Also, the use case you've quoted means you may delete more than you expect if you strike a Zip file that unzips as just a bunch of files, rather than a bunch of files inside a containing folder. And since most Zip files do include a containing folder, this is the kind of thing that will bite you right when you've been lulled into a false sense of security.

Personally, I'd just right-click, choose "Open containing folder", hit the Up button, and delete the folder the usual way. Two extra clicks is cheap accident insurance.
posted by flabdablet at 5:44 PM on October 20, 2008


Here's an article that shows you the registry keys you need to tweak to add things to the Explorer right-click menu. You can use this method to invoke delete-me-and-my-folder.cmd via a right-click menu item instead of via drag and drop.

Be aware, though, that it will treat shortcuts differently if you do this. With drag and drop, the script will delete the folder containing the shortcut; with right-click launch, it will delete the folder containing the item the shortcut points to.

All in all, this idea strikes me as horribly dangerous and I recommend not pursuing it.
posted by flabdablet at 6:15 PM on October 20, 2008


Best answer: Answering this question is like picking scabs. I know I shouldn't keep doing it but it's so tempting.

There's actually no need to fartarse about with the registry. If you save a shortcut to the script in the %userprofile%\SendTo folder, it will show up in the right-click menu's Send To submenu.

This gets you a right-click launch option that works exactly the same way the drag and drop option does (it doesn't dereference shortcuts before processing the containing folder).

You can even put the script itself in the SendTo folder instead of a shortcut, if you don't mind the .cmd filename extension showing up in the Send To menu.
posted by flabdablet at 11:32 PM on October 20, 2008


Response by poster: flabdablet: rmdir /s "%~dp1" works except I had to add 'cd C:\Users\paul' before the command, otherwise it wouldn't delete the containing folder because I would be in the folder. I have it set up as a shortcut in the SendTo menu and it does exactly what I want.

thanks.
posted by dazzle at 7:53 AM on October 22, 2008


otherwise it wouldn't delete the containing folder because I would be in the folder

The current directory for a script is usually set, by default, to the directory the script is in rather than the directory its first argument is in, so I'm surprised to hear that. I must admit, though, that I did all my testing using a script containing dir instead of rmdir because I didn't want to delete anything by accident.

If you're testing the script by feeding it things from a standard Explorer window as opposed to a search results window, it may be Explorer rather than the script itself that's locking the folder you're trying to delete by setting it as the current directory. If that's the case, I wouldn't expect that a cd command inside the script would achieve much.

You can change the Start In property of the shortcut that launches the script to anything you like, if you'd rather set the script's current directory explicitly before it starts instead of relying on the default.
posted by flabdablet at 9:46 AM on October 22, 2008


Response by poster: I changed the Start In property to my home directory, removed the cd command from the script and it still works as expected. Thanks.
posted by dazzle at 9:28 AM on October 23, 2008


« Older Erratic network behavior   |   Pregnancy Related Carpal Tunnel relief? Newer »
This thread is closed to new comments.